Skip to content

Commit

Permalink
Adjust Step::forward_checked docs for large types
Browse files Browse the repository at this point in the history
Co-Authored-By: Nadrieril Feneanar <[email protected]>
  • Loading branch information
CAD97 and Nadrieril committed Apr 8, 2020
1 parent 2fcfd23 commit f34322d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
7 changes: 5 additions & 2 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ pub unsafe trait Step: Clone + PartialOrd + Sized {
///
/// 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)) == try { Step::forward_checked(a, n.checked_add(m)?) }`
/// * `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))`
///
/// 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`:
///
Expand Down
12 changes: 2 additions & 10 deletions src/libcore/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,7 @@ fn test_iterator_chain_size_hint() {
}

fn size_hint(&self) -> (usize, Option<usize>) {
if self.is_empty {
(0, Some(0))
} else {
(1, Some(1))
}
if self.is_empty { (0, Some(0)) } else { (1, Some(1)) }
}
}

Expand Down Expand Up @@ -1558,11 +1554,7 @@ fn test_find_map() {
assert_eq!(iter.next(), Some(&7));

fn half_if_even(x: &isize) -> Option<isize> {
if x % 2 == 0 {
Some(x / 2)
} else {
None
}
if x % 2 == 0 { Some(x / 2) } else { None }
}
}

Expand Down

0 comments on commit f34322d

Please sign in to comment.