about summary refs log tree commit diff
diff options
context:
space:
mode:
authorYuki Okushi <huyuumi.dev+love@gmail.com>2022-11-07 09:46:29 +0900
committerGitHub <noreply@github.com>2022-11-07 09:46:29 +0900
commit7ca833efe07a918f3ba89630da312d3fd6a85e01 (patch)
treea551182bfce55b37e2ba49f98be4796bf1e94093
parent02a0bdee0da2b1462463468909a656d10c412e30 (diff)
parenta398e09e42b9b3263dd20d45b1c6f1fd4fe8ce3b (diff)
downloadrust-7ca833efe07a918f3ba89630da312d3fd6a85e01.tar.gz
rust-7ca833efe07a918f3ba89630da312d3fd6a85e01.zip
Rollup merge of #104074 - yancyribbens:add-example-to-round, r=Mark-Simulacrum
rustdoc: Add an example for round that is different from truncate

The current examples for [round](https://github.com/rust-lang/rust/blob/master/library/std/src/f64.rs#L75) would have the same results as the example for [truncate](https://github.com/rust-lang/rust/blob/master/library/std/src/f64.rs#L95).  This PR adds one more example to `round` that will have a different result 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"]