Skip to content

Commit 7ca833e

Browse files
author
Yuki Okushi
authored
Rollup merge of rust-lang#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`.
2 parents 02a0bde + a398e09 commit 7ca833e

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

Diff for: library/std/src/f32.rs

+2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ impl f32 {
7777
/// ```
7878
/// let f = 3.3_f32;
7979
/// let g = -3.3_f32;
80+
/// let h = -3.7_f32;
8081
///
8182
/// assert_eq!(f.round(), 3.0);
8283
/// assert_eq!(g.round(), -3.0);
84+
/// assert_eq!(h.round(), -4.0);
8385
/// ```
8486
#[rustc_allow_incoherent_impl]
8587
#[must_use = "method returns a new number and does not mutate the original value"]

Diff for: library/std/src/f64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,11 @@ impl f64 {
7777
/// ```
7878
/// let f = 3.3_f64;
7979
/// let g = -3.3_f64;
80+
/// let h = -3.7_f64;
8081
///
8182
/// assert_eq!(f.round(), 3.0);
8283
/// assert_eq!(g.round(), -3.0);
84+
/// assert_eq!(h.round(), -4.0);
8385
/// ```
8486
#[rustc_allow_incoherent_impl]
8587
#[must_use = "method returns a new number and does not mutate the original value"]

0 commit comments

Comments
 (0)