Auto merge of #85601 - klensy:padint-example-fix, r=dtolnay
fix pad_integral example pad_integral's parameter `is_nonnegative - whether the original integer was either positive or zero`, but in example it checked as `self.nb > 0`, so it previously printed `-0` for `format!("{}", Foo::new(0)`, what is wrong.
This commit is contained in:
commit
6f6919231e
1 changed files with 2 additions and 1 deletions
|
@ -1245,12 +1245,13 @@ impl<'a> Formatter<'a> {
|
||||||
/// // We need to remove "-" from the number output.
|
/// // We need to remove "-" from the number output.
|
||||||
/// let tmp = self.nb.abs().to_string();
|
/// let tmp = self.nb.abs().to_string();
|
||||||
///
|
///
|
||||||
/// formatter.pad_integral(self.nb > 0, "Foo ", &tmp)
|
/// formatter.pad_integral(self.nb >= 0, "Foo ", &tmp)
|
||||||
/// }
|
/// }
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// assert_eq!(&format!("{}", Foo::new(2)), "2");
|
/// assert_eq!(&format!("{}", Foo::new(2)), "2");
|
||||||
/// assert_eq!(&format!("{}", Foo::new(-1)), "-1");
|
/// assert_eq!(&format!("{}", Foo::new(-1)), "-1");
|
||||||
|
/// assert_eq!(&format!("{}", Foo::new(0)), "0");
|
||||||
/// assert_eq!(&format!("{:#}", Foo::new(-1)), "-Foo 1");
|
/// assert_eq!(&format!("{:#}", Foo::new(-1)), "-Foo 1");
|
||||||
/// assert_eq!(&format!("{:0>#8}", Foo::new(-1)), "00-Foo 1");
|
/// assert_eq!(&format!("{:0>#8}", Foo::new(-1)), "00-Foo 1");
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue