From e753f305439c7c6cb7f485b6c52f930aefaa2a77 Mon Sep 17 00:00:00 2001 From: David Thompson Date: Wed, 14 Jul 2021 13:48:18 -0700 Subject: [PATCH] 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. --- library/core/src/iter/range.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/iter/range.rs b/library/core/src/iter/range.rs index 4a86d6a100abe..b9387ef49e5fb 100644 --- a/library/core/src/iter/range.rs +++ b/library/core/src/iter/range.rs @@ -30,7 +30,7 @@ pub trait Step: Clone + PartialOrd + Sized { /// For any `a`, `b`, and `n`: /// /// * `steps_between(&a, &b) == Some(n)` if and only if `Step::forward_checked(&a, n) == Some(b)` - /// * `steps_between(&a, &b) == Some(n)` if and only if `Step::backward_checked(&a, n) == Some(a)` + /// * `steps_between(&a, &b) == Some(n)` if and only if `Step::backward_checked(&b, n) == Some(a)` /// * `steps_between(&a, &b) == Some(n)` only if `a <= b` /// * Corollary: `steps_between(&a, &b) == Some(0)` if and only if `a == b` /// * Note that `a <= b` does _not_ imply `steps_between(&a, &b) != None`;