Point out that total_cmp is no strict superset of partial comparison

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.
This commit is contained in:
est31 2020-11-01 14:27:36 +01:00
parent 4d247ad7d3
commit a79059d42d
2 changed files with 8 additions and 0 deletions

View file

@ -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)]

View file

@ -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)]