Skip to content

Commit f34322d

Browse files
CAD97Nadrieril
andcommitted
Adjust Step::forward_checked docs for large types
Co-Authored-By: Nadrieril Feneanar <[email protected]>
1 parent 2fcfd23 commit f34322d

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

src/libcore/iter/range.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ pub unsafe trait Step: Clone + PartialOrd + Sized {
4545
///
4646
/// For any `a`, `n`, and `m`:
4747
///
48-
/// * `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))`
49-
/// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == try { Step::forward_checked(a, n.checked_add(m)?) }`
48+
/// * `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))`
49+
///
50+
/// For any `a`, `n`, and `m` where `n + m` does not overflow:
51+
///
52+
/// * `Step::forward_checked(a, n).and_then(|x| Step::forward_checked(x, m)) == Step::forward_checked(a, n + m)`
5053
///
5154
/// For any `a` and `n`:
5255
///

src/libcore/tests/iter.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,7 @@ fn test_iterator_chain_size_hint() {
228228
}
229229

230230
fn size_hint(&self) -> (usize, Option<usize>) {
231-
if self.is_empty {
232-
(0, Some(0))
233-
} else {
234-
(1, Some(1))
235-
}
231+
if self.is_empty { (0, Some(0)) } else { (1, Some(1)) }
236232
}
237233
}
238234

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

15601556
fn half_if_even(x: &isize) -> Option<isize> {
1561-
if x % 2 == 0 {
1562-
Some(x / 2)
1563-
} else {
1564-
None
1565-
}
1557+
if x % 2 == 0 { Some(x / 2) } else { None }
15661558
}
15671559
}
15681560

0 commit comments

Comments
 (0)