Skip to content

Commit ecdf48e

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 b0d3958 commit ecdf48e

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
@@ -292,7 +292,7 @@ pub struct FormattingOptions {
292292
sign_aware_zero_pad: bool,
293293
alternate: bool,
294294
fill: char,
295-
alignment: Option<Alignment>,
295+
align: Option<Alignment>,
296296
width: Option<usize>,
297297
precision: Option<usize>,
298298
debug_as_hex: Option<DebugAsHex>,
@@ -316,7 +316,7 @@ impl FormattingOptions {
316316
sign_aware_zero_pad: false,
317317
alternate: false,
318318
fill: ' ',
319-
alignment: None,
319+
align: None,
320320
width: None,
321321
precision: None,
322322
debug_as_hex: None,
@@ -373,15 +373,15 @@ impl FormattingOptions {
373373
/// The alignment specifies how the value being formatted should be
374374
/// positioned if it is smaller than the width of the formatter.
375375
#[unstable(feature = "formatting_options", issue = "118117")]
376-
pub fn alignment(&mut self, alignment: Option<Alignment>) -> &mut Self {
377-
self.alignment = alignment;
376+
pub fn align(&mut self, align: Option<Alignment>) -> &mut Self {
377+
self.align = align;
378378
self
379379
}
380380
/// Sets or removes the width.
381381
///
382382
/// This is a parameter for the “minimum width” that the format should take
383383
/// up. If the value’s string does not fill up this many characters, then
384-
/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::alignment`]
384+
/// the padding specified by [`FormattingOptions::fill`]/[`FormattingOptions::align`]
385385
/// will be used to take up the required space.
386386
#[unstable(feature = "formatting_options", issue = "118117")]
387387
pub fn width(&mut self, width: Option<usize>) -> &mut Self {
@@ -432,8 +432,8 @@ impl FormattingOptions {
432432
}
433433
/// Returns the current alignment.
434434
#[unstable(feature = "formatting_options", issue = "118117")]
435-
pub fn get_alignment(&self) -> Option<Alignment> {
436-
self.alignment
435+
pub fn get_align(&self) -> Option<Alignment> {
436+
self.align
437437
}
438438
/// Returns the current width.
439439
#[unstable(feature = "formatting_options", issue = "118117")]
@@ -1459,7 +1459,7 @@ pub fn write(output: &mut dyn Write, args: Arguments<'_>) -> Result {
14591459

14601460
unsafe fn run(fmt: &mut Formatter<'_>, arg: &rt::Placeholder, args: &[rt::Argument<'_>]) -> Result {
14611461
fmt.options.fill(arg.fill);
1462-
fmt.options.alignment(arg.align.into());
1462+
fmt.options.align(arg.align.into());
14631463
fmt.options.flags(arg.flags);
14641464
// SAFETY: arg and args come from the same Arguments,
14651465
// which guarantees the indexes are always within bounds.
@@ -1623,13 +1623,13 @@ impl<'a> Formatter<'a> {
16231623
Some(min) if self.sign_aware_zero_pad() => {
16241624
let old_fill = crate::mem::replace(&mut self.options.fill, '0');
16251625
let old_align =
1626-
crate::mem::replace(&mut self.options.alignment, Some(Alignment::Right));
1626+
crate::mem::replace(&mut self.options.align, Some(Alignment::Right));
16271627
write_prefix(self, sign, prefix)?;
16281628
let post_padding = self.padding(min - width, Alignment::Right)?;
16291629
self.buf.write_str(buf)?;
16301630
post_padding.write(self)?;
16311631
self.options.fill = old_fill;
1632-
self.options.alignment = old_align;
1632+
self.options.align = old_align;
16331633
Ok(())
16341634
}
16351635
// Otherwise, the sign and prefix goes after the padding
@@ -1767,7 +1767,7 @@ impl<'a> Formatter<'a> {
17671767
formatted.sign = "";
17681768
width = width.saturating_sub(sign.len());
17691769
self.options.fill('0');
1770-
self.options.alignment(Some(Alignment::Right));
1770+
self.options.align(Some(Alignment::Right));
17711771
}
17721772

17731773
// remaining parts go through the ordinary padding process.
@@ -1785,7 +1785,7 @@ impl<'a> Formatter<'a> {
17851785
post_padding.write(self)
17861786
};
17871787
self.options.fill(old_fill);
1788-
self.options.alignment(old_align);
1788+
self.options.align(old_align);
17891789
ret
17901790
} else {
17911791
// this is the common case and we take a shortcut
@@ -1979,7 +1979,7 @@ impl<'a> Formatter<'a> {
19791979
#[must_use]
19801980
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
19811981
pub fn align(&self) -> Option<Alignment> {
1982-
self.options.get_alignment()
1982+
self.options.get_align()
19831983
}
19841984

19851985
/// Returns the optionally specified integer width that the output should be.

0 commit comments

Comments
 (0)