about summary refs log tree commit diff
diff options
context:
space:
mode:
authoryancy <yancy@yancy.lol>2022-11-06 23:05:16 +0100
committeryancy <yancy@yancy.lol>2022-11-06 23:05:16 +0100
commita398e09e42b9b3263dd20d45b1c6f1fd4fe8ce3b (patch)
tree1a25e824e41ce20cdd0babbd46bfe43308eee550
parent534ddc6166a9031b0c269544929d68f2539ea7a0 (diff)
downloadrust-a398e09e42b9b3263dd20d45b1c6f1fd4fe8ce3b.tar.gz
rust-a398e09e42b9b3263dd20d45b1c6f1fd4fe8ce3b.zip
rustdoc: Add an example for round that is different from truncate
-rw-r--r--library/std/src/f32.rs2
-rw-r--r--library/std/src/f64.rs2
2 files changed, 4 insertions, 0 deletions
diff --git a/library/std/src/f32.rs b/library/std/src/f32.rs
index dafcd876744..4127c4056f2 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 77048f9a28f..cc64258da60 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"]