We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 3b507aa + e156214 commit 2b22fc9Copy full SHA for 2b22fc9
docs/dev/style.md
@@ -769,14 +769,20 @@ fn foo() -> Option<Bar> {
769
770
## Comparisons
771
772
-Use `<`/`<=`, avoid `>`/`>=`.
+When doing multiple comparisons use `<`/`<=`, avoid `>`/`>=`.
773
774
```rust
775
// GOOD
776
assert!(lo <= x && x <= hi);
777
+assert!(r1 < l2 || r2 < l1);
778
+assert!(x < y);
779
+assert!(x > 0);
780
781
// BAD
782
assert!(x >= lo && x <= hi>);
783
+assert!(r1 < l2 || l1 > r2);
784
+assert!(y > x);
785
+assert!(0 > x);
786
```
787
788
**Rationale:** Less-then comparisons are more intuitive, they correspond spatially to [real line](https://en.wikipedia.org/wiki/Real_line).
0 commit comments