Skip to content

Commit 36de877

Browse files
Rollup merge of #87138 - dhwthompson:fix-range-invariant, r=JohnTitor
Correct invariant documentation for `steps_between` Given that the previous example involves stepping forward from A to B, the equivalent example on this line would make most sense as stepping backward from B to A. I should probably add a caveat here that I’m fairly new to Rust, and this is my first contribution to this repo, so it’s very possible that I’ve misunderstood how this is supposed to work (either on a technical level or a social one). If this is the case, please do let me know.
2 parents c1ffca0 + e753f30 commit 36de877

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Diff for: library/core/src/iter/range.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub trait Step: Clone + PartialOrd + Sized {
3030
/// For any `a`, `b`, and `n`:
3131
///
3232
/// * `steps_between(&a, &b) == Some(n)` if and only if `Step::forward_checked(&a, n) == Some(b)`
33-
/// * `steps_between(&a, &b) == Some(n)` if and only if `Step::backward_checked(&a, n) == Some(a)`
33+
/// * `steps_between(&a, &b) == Some(n)` if and only if `Step::backward_checked(&b, n) == Some(a)`
3434
/// * `steps_between(&a, &b) == Some(n)` only if `a <= b`
3535
/// * Corollary: `steps_between(&a, &b) == Some(0)` if and only if `a == b`
3636
/// * Note that `a <= b` does _not_ imply `steps_between(&a, &b) != None`;

0 commit comments

Comments
 (0)