Skip to content

Commit 1872642

Browse files
camsteffenytmimi
authored andcommitted
Use 'delta' for Shape args
Avoid "width" since it can get confused with the width field.
1 parent 777e25a commit 1872642

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/shape.rs

+20-20
Original file line numberDiff line numberDiff line change
@@ -188,38 +188,38 @@ impl Shape {
188188
}
189189
}
190190

191-
pub(crate) fn visual_indent(&self, extra_width: usize) -> Shape {
192-
let alignment = self.offset + extra_width;
191+
pub(crate) fn visual_indent(&self, delta: usize) -> Shape {
192+
let alignment = self.offset + delta;
193193
Shape {
194194
width: self.width,
195195
indent: Indent::new(self.indent.block_indent, alignment),
196196
offset: alignment,
197197
}
198198
}
199199

200-
pub(crate) fn block_indent(&self, extra_width: usize) -> Shape {
200+
pub(crate) fn block_indent(&self, delta: usize) -> Shape {
201201
if self.indent.alignment == 0 {
202202
Shape {
203203
width: self.width,
204-
indent: Indent::new(self.indent.block_indent + extra_width, 0),
204+
indent: Indent::new(self.indent.block_indent + delta, 0),
205205
offset: 0,
206206
}
207207
} else {
208208
Shape {
209209
width: self.width,
210-
indent: self.indent + extra_width,
211-
offset: self.indent.alignment + extra_width,
210+
indent: self.indent + delta,
211+
offset: self.indent.alignment + delta,
212212
}
213213
}
214214
}
215215

216-
pub(crate) fn block_left(&self, width: usize) -> Option<Shape> {
217-
self.block_indent(width).sub_width(width)
216+
pub(crate) fn block_left(&self, delta: usize) -> Option<Shape> {
217+
self.block_indent(delta).sub_width(delta)
218218
}
219219

220-
pub(crate) fn add_offset(&self, extra_width: usize) -> Shape {
220+
pub(crate) fn add_offset(&self, delta: usize) -> Shape {
221221
Shape {
222-
offset: self.offset + extra_width,
222+
offset: self.offset + delta,
223223
..*self
224224
}
225225
}
@@ -231,27 +231,27 @@ impl Shape {
231231
}
232232
}
233233

234-
pub(crate) fn saturating_sub_width(&self, width: usize) -> Shape {
235-
self.sub_width(width).unwrap_or(Shape { width: 0, ..*self })
234+
pub(crate) fn saturating_sub_width(&self, delta: usize) -> Shape {
235+
self.sub_width(delta).unwrap_or(Shape { width: 0, ..*self })
236236
}
237237

238-
pub(crate) fn sub_width(&self, width: usize) -> Option<Shape> {
238+
pub(crate) fn sub_width(&self, n: usize) -> Option<Shape> {
239239
Some(Shape {
240-
width: self.width.checked_sub(width)?,
240+
width: self.width.checked_sub(n)?,
241241
..*self
242242
})
243243
}
244244

245-
pub(crate) fn shrink_left(&self, width: usize) -> Option<Shape> {
245+
pub(crate) fn shrink_left(&self, delta: usize) -> Option<Shape> {
246246
Some(Shape {
247-
width: self.width.checked_sub(width)?,
248-
indent: self.indent + width,
249-
offset: self.offset + width,
247+
width: self.width.checked_sub(delta)?,
248+
indent: self.indent + delta,
249+
offset: self.offset + delta,
250250
})
251251
}
252252

253-
pub(crate) fn offset_left(&self, width: usize) -> Option<Shape> {
254-
self.add_offset(width).sub_width(width)
253+
pub(crate) fn offset_left(&self, delta: usize) -> Option<Shape> {
254+
self.add_offset(delta).sub_width(delta)
255255
}
256256

257257
pub(crate) fn used_width(&self) -> usize {

0 commit comments

Comments
 (0)