]> git.lizzy.rs Git - rust.git/commitdiff
Correct invariant documentation for `steps_between`
authorDavid Thompson <dhwthompson@gmail.com>
Wed, 14 Jul 2021 20:48:18 +0000 (13:48 -0700)
committerDavid Thompson <dhwthompson@gmail.com>
Wed, 14 Jul 2021 20:48:18 +0000 (13:48 -0700)
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

index 4a86d6a100abe66539a41037cfe2de4db9dbb9cd..b9387ef49e5fb211ab343869a8a534c3c262f487 100644 (file)
@@ -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`;