diff options
Diffstat (limited to 'src/tools/clippy/src/docs/neg_cmp_op_on_partial_ord.txt')
-rw-r--r-- | src/tools/clippy/src/docs/neg_cmp_op_on_partial_ord.txt | 26 |
1 files changed, 0 insertions, 26 deletions
diff --git a/src/tools/clippy/src/docs/neg_cmp_op_on_partial_ord.txt b/src/tools/clippy/src/docs/neg_cmp_op_on_partial_ord.txt deleted file mode 100644 index fa55c6cfd..000000000 --- a/src/tools/clippy/src/docs/neg_cmp_op_on_partial_ord.txt +++ /dev/null @@ -1,26 +0,0 @@ -### What it does -Checks for the usage of negated comparison operators on types which only implement -`PartialOrd` (e.g., `f64`). - -### Why is this bad? -These operators make it easy to forget that the underlying types actually allow not only three -potential Orderings (Less, Equal, Greater) but also a fourth one (Uncomparable). This is -especially easy to miss if the operator based comparison result is negated. - -### Example -``` -let a = 1.0; -let b = f64::NAN; - -let not_less_or_equal = !(a <= b); -``` - -Use instead: -``` -use std::cmp::Ordering; - -let _not_less_or_equal = match a.partial_cmp(&b) { - None | Some(Ordering::Greater) => true, - _ => false, -}; -```
\ No newline at end of file |