Adjust Step::forward_checked docs for large types
Co-Authored-By: Nadrieril Feneanar <nadrieril@users.noreply.github.com>
This commit is contained in:
@@ -45,8 +45,11 @@ pub unsafe trait Step: Clone + PartialOrd + Sized {
|
|||||||
///
|
///
|
||||||
/// For any `a`, `n`, and `m`:
|
/// For any `a`, `n`, and `m`:
|
||||||
///
|
///
|
||||||
/// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == n.checked_add(m).and_then(|x| Step::forward_checked(a, x))`
|
/// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == Step::forward_checked(a, m).and_then(|x| Step::forward_checked(x, n))`
|
||||||
/// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == try { Step::forward_checked(a, n.checked_add(m)?) }`
|
///
|
||||||
|
/// For any `a`, `n`, and `m` where `n + m` does not overflow:
|
||||||
|
///
|
||||||
|
/// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == Step::forward_checked(a, n + m)`
|
||||||
///
|
///
|
||||||
/// For any `a` and `n`:
|
/// For any `a` and `n`:
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -228,11 +228,7 @@ fn test_iterator_chain_size_hint() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn size_hint(&self) -> (usize, Option<usize>) {
|
fn size_hint(&self) -> (usize, Option<usize>) {
|
||||||
if self.is_empty {
|
if self.is_empty { (0, Some(0)) } else { (1, Some(1)) }
|
||||||
(0, Some(0))
|
|
||||||
} else {
|
|
||||||
(1, Some(1))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1558,11 +1554,7 @@ fn test_find_map() {
|
|||||||
assert_eq!(iter.next(), Some(&7));
|
assert_eq!(iter.next(), Some(&7));
|
||||||
|
|
||||||
fn half_if_even(x: &isize) -> Option<isize> {
|
fn half_if_even(x: &isize) -> Option<isize> {
|
||||||
if x % 2 == 0 {
|
if x % 2 == 0 { Some(x / 2) } else { None }
|
||||||
Some(x / 2)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user