From 1dac6da408dac324e51e2e615483c72e358d9725 Mon Sep 17 00:00:00 2001 From: Maurits van Riezen <12109031+mousetail@users.noreply.github.com> Date: Wed, 7 Sep 2022 14:01:30 +0200 Subject: [PATCH 1/3] This example was broken The provided example to the `sign_plus` method on `fmt` is broken, it displays the `-` sign twice for negative numbers. --- library/core/src/fmt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 9d3e9abf55779..0d370e3843174 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1819,7 +1819,7 @@ impl<'a> Formatter<'a> { /// write!(formatter, /// "Foo({}{})", /// if self.0 < 0 { '-' } else { '+' }, - /// self.0) + /// self.0.abs()) /// } else { /// write!(formatter, "Foo({})", self.0) /// } From 0a9b49c794a4179a4dcfd5fc07cea76321e51ad0 Mon Sep 17 00:00:00 2001 From: Maurits van Riezen <12109031+mousetail@users.noreply.github.com> Date: Wed, 7 Sep 2022 16:36:32 +0200 Subject: [PATCH 2/3] Add doctest --- library/core/src/fmt/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 0d370e3843174..1abb729a4c007 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1827,6 +1827,7 @@ impl<'a> Formatter<'a> { /// } /// /// assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)"); + /// assert_eq!(&format!("{:+}", Foo(-32)), "Foo(-23)"); /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)"); /// ``` #[must_use] From 5fbe485ecca977e3981d9dbcc5370183528d50a7 Mon Sep 17 00:00:00 2001 From: Maurits van Riezen <12109031+mousetail@users.noreply.github.com> Date: Wed, 7 Sep 2022 17:53:47 +0200 Subject: [PATCH 3/3] Typo --- library/core/src/fmt/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/fmt/mod.rs b/library/core/src/fmt/mod.rs index 1abb729a4c007..905212eb372b1 100644 --- a/library/core/src/fmt/mod.rs +++ b/library/core/src/fmt/mod.rs @@ -1827,7 +1827,7 @@ impl<'a> Formatter<'a> { /// } /// /// assert_eq!(&format!("{:+}", Foo(23)), "Foo(+23)"); - /// assert_eq!(&format!("{:+}", Foo(-32)), "Foo(-23)"); + /// assert_eq!(&format!("{:+}", Foo(-23)), "Foo(-23)"); /// assert_eq!(&format!("{}", Foo(23)), "Foo(23)"); /// ``` #[must_use]