Skip to content

Commit

Permalink
Point out that total_cmp is no strict superset of partial comparison
Browse files Browse the repository at this point in the history
Partial comparison and total_cmp are not equal. This helps
preventing the mistake of creating float wrappers that
base their Ord impl on total_cmp and their PartialOrd impl on
the PartialOrd impl of the float type. PartialOrd and Ord
are required to agree with each other.
  • Loading branch information
est31 committed Nov 1, 2020
1 parent 4d247ad commit a79059d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,10 @@ impl f32 {
/// - Positive signaling NaN
/// - Positive quiet NaN
///
/// Note that this function does not always agree with the [`PartialOrd`]
/// and [`PartialEq`] implementations of `f32`. In particular, they regard
/// negative and positive zero as equal, while `total_cmp` doesn't.
///
/// # Example
/// ```
/// #![feature(total_cmp)]
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,10 @@ impl f64 {
/// - Positive signaling NaN
/// - Positive quiet NaN
///
/// Note that this function does not always agree with the [`PartialOrd`]
/// and [`PartialEq`] implementations of `f64`. In particular, they regard
/// negative and positive zero as equal, while `total_cmp` doesn't.
///
/// # Example
/// ```
/// #![feature(total_cmp)]
Expand Down

0 comments on commit a79059d

Please sign in to comment.