Skip to content

Commit

Permalink
Expose tests for {f32,f64}.total_cmp in docs
Browse files Browse the repository at this point in the history
Uncomment the helpful assert_eq! line, which is stripped out
completely in docs, and leaves the reader to mentally play
through the algorithm, or go to the playground and add a println!,
to see what the result will be.

(If these tests are known to fail on some platforms, is there
some mechanism to conditionalize this or escape the comments so
the assert_eq! source will be visible on the web?)
  • Loading branch information
eswartz committed Aug 31, 2023
1 parent 784916c commit b7d8417
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1385,9 +1385,9 @@ impl f32 {
/// ];
///
/// bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
/// # assert!(bois.into_iter().map(|b| b.weight)
/// # .zip([-5.0, 0.1, 10.0, 99.0, f32::INFINITY, f32::NAN].iter())
/// # .all(|(a, b)| a.to_bits() == b.to_bits()))
/// assert!(bois.into_iter().map(|b| b.weight)
/// .zip([-5.0, 0.1, 10.0, 99.0, f32::INFINITY, f32::NAN].iter())
/// .all(|(a, b)| a.to_bits() == b.to_bits()))
/// ```
#[stable(feature = "total_cmp", since = "1.62.0")]
#[must_use]
Expand Down
6 changes: 3 additions & 3 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1383,9 +1383,9 @@ impl f64 {
/// ];
///
/// bois.sort_by(|a, b| a.weight.total_cmp(&b.weight));
/// # assert!(bois.into_iter().map(|b| b.weight)
/// # .zip([-5.0, 0.1, 10.0, 99.0, f64::INFINITY, f64::NAN].iter())
/// # .all(|(a, b)| a.to_bits() == b.to_bits()))
/// assert!(bois.into_iter().map(|b| b.weight)
/// .zip([-5.0, 0.1, 10.0, 99.0, f64::INFINITY, f64::NAN].iter())
/// .all(|(a, b)| a.to_bits() == b.to_bits()))
/// ```
#[stable(feature = "total_cmp", since = "1.62.0")]
#[must_use]
Expand Down

0 comments on commit b7d8417

Please sign in to comment.