Skip to content

Commit 385944a

Browse files
committed
fmt::FormattingOptions: Renamed alignment to align
Likewise for `get_alignment`. This is how the method is named on `Formatter`, I want to keep it consistent.
1 parent f71232e commit 385944a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

library/core/src/fmt/mod.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ pub struct FormattingOptions {
276276
sign_aware_zero_pad: bool,
277277
alternate: bool,
278278
fill: char,
279-
alignment: Option<Alignment>,
279+
align: Option<Alignment>,
280280
width: Option<usize>,
281281
precision: Option<usize>,
282282
debug_as_hex: Option<DebugAsHex>,
@@ -300,7 +300,7 @@ impl FormattingOptions {
300300
sign_aware_zero_pad: false,
301301
alternate: false,
302302
fill: ' ',
303-
alignment: None,
303+
align: None,
304304
width: None,
305305
precision: None,
306306
debug_as_hex: None,
@@ -357,15 +357,15 @@ impl FormattingOptions {
357357
/// The alignment specifies how the value being formatted should be
358358
/// positioned if it is smaller than the width of the formatter.
359359
#[unstable(feature = "formatting_options", issue = "118117")]
360-
pub fn alignment(&mut self, alignment: Option<Alignment>) -> &mut Self {
361-
self.alignment = alignment;
360+
pub fn align(&mut self, align: Option<Alignment>) -> &mut Self {
361+
self.align = align;
362362
self
363363
}
364364
/// Sets or removes the width.
365365
///
366366
/// This is a parameter for the “minimum width” that the format should take
367367
/// up. If the value’s string does not fill up this many characters, then
368-
/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::alignment`]
368+
/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`]
369369
/// will be used to take up the required space.
370370
#[unstable(feature = "formatting_options", issue = "118117")]
371371
pub fn width(&mut self, width: Option<usize>) -> &mut Self {
@@ -416,8 +416,8 @@ impl FormattingOptions {
416416
}
417417
/// Returns the current alignment.
418418
#[unstable(feature = "formatting_options", issue = "118117")]
419-
pub fn get_alignment(&self) -> Option<Alignment> {
420-
self.alignment
419+
pub fn get_align(&self) -> Option<Alignment> {
420+
self.align
421421
}
422422
/// Returns the current width.
423423
#[unstable(feature = "formatting_options", issue = "118117")]
@@ -1393,7 +1393,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
13931393

13941394
unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[rt::Argument<'_>]) -> Result {
13951395
fmt.options.fill(arg.fill);
1396-
fmt.options.alignment(arg.align.into());
1396+
fmt.options.align(arg.align.into());
13971397
fmt.options.flags(arg.flags);
13981398
// SAFETY: arg and args come from the same Arguments,
13991399
// which guarantees the indexes are always within bounds.
@@ -1556,13 +1556,13 @@ impl<'a> Formatter<'a> {
15561556
Some(min) if self.sign_aware_zero_pad() => {
15571557
let old_fill = crate::mem::replace(&mut self.options.fill, '0');
15581558
let old_align =
1559-
crate::mem::replace(&mut self.options.alignment, Some(Alignment::Right));
1559+
crate::mem::replace(&mut self.options.align, Some(Alignment::Right));
15601560
write_prefix(self, sign, prefix)?;
15611561
let post_padding = self.padding(min - width, Alignment::Right)?;
15621562
self.buf.write_str(buf)?;
15631563
post_padding.write(self)?;
15641564
self.options.fill = old_fill;
1565-
self.options.alignment = old_align;
1565+
self.options.align = old_align;
15661566
Ok(())
15671567
}
15681568
// Otherwise, the sign and prefix goes after the padding
@@ -1697,7 +1697,7 @@ impl<'a> Formatter<'a> {
16971697
formatted.sign = "";
16981698
width = width.saturating_sub(sign.len());
16991699
self.options.fill('0');
1700-
self.options.alignment(Some(Alignment::Right));
1700+
self.options.align(Some(Alignment::Right));
17011701
}
17021702

17031703
// remaining parts go through the ordinary padding process.
@@ -1715,7 +1715,7 @@ impl<'a> Formatter<'a> {
17151715
post_padding.write(self)
17161716
};
17171717
self.options.fill(old_fill);
1718-
self.options.alignment(old_align);
1718+
self.options.align(old_align);
17191719
ret
17201720
} else {
17211721
// this is the common case and we take a shortcut
@@ -1899,7 +1899,7 @@ impl<'a> Formatter<'a> {
18991899
#[must_use]
19001900
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
19011901
pub fn align(&self) -> Option<Alignment> {
1902-
self.options.get_alignment()
1902+
self.options.get_align()
19031903
}
19041904

19051905
/// Optionally specified integer width that the output should be.

0 commit comments

Comments
 (0)