From a398e09e42b9b3263dd20d45b1c6f1fd4fe8ce3b Mon Sep 17 00:00:00 2001 From: yancy Date: Sun, 6 Nov 2022 23:05:16 +0100 Subject: [PATCH] rustdoc: Add an example for round that is different from truncate --- library/std/src/f32.rs | 2 ++ library/std/src/f64.rs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs index dafcd87674412..4127c4056f24e 100644 --- a/library/std/src/f32.rs +++ b/library/std/src/f32.rs @@ -77,9 +77,11 @@ impl f32 { /// ``` /// let f = 3.3_f32; /// let g = -3.3_f32; + /// let h = -3.7_f32; /// /// assert_eq!(f.round(), 3.0); /// assert_eq!(g.round(), -3.0); + /// assert_eq!(h.round(), -4.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"] diff --git a/library/std/src/f64.rs b/library/std/src/f64.rs index 77048f9a28f25..cc64258da60d1 100644 --- a/library/std/src/f64.rs +++ b/library/std/src/f64.rs @@ -77,9 +77,11 @@ impl f64 { /// ``` /// let f = 3.3_f64; /// let g = -3.3_f64; + /// let h = -3.7_f64; /// /// assert_eq!(f.round(), 3.0); /// assert_eq!(g.round(), -3.0); + /// assert_eq!(h.round(), -4.0); /// ``` #[rustc_allow_incoherent_impl] #[must_use = "method returns a new number and does not mutate the original value"]