Fix example code for unreachable!
The previous code was giving an incorrect result (not x/3).
This commit is contained in:
parent
82fc1aa875
commit
f01cbaa0ba
1 changed files with 4 additions and 5 deletions
|
@ -217,12 +217,11 @@ macro_rules! debug_assert_eq(
|
||||||
/// Iterators:
|
/// Iterators:
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust
|
||||||
/// fn divide_by_three(x: i32) -> i32 { // one of the poorest implementations of x/3
|
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
|
||||||
/// for i in std::iter::count(0_i32, 1) {
|
/// for i in std::iter::count(0_u32, 1) {
|
||||||
/// if i < 0 { panic!("i32 overflow"); }
|
/// if 3*i < i { panic!("u32 overflow"); }
|
||||||
/// if x < 3*i { return i; }
|
/// if x < 3*i { return i-1; }
|
||||||
/// }
|
/// }
|
||||||
///
|
|
||||||
/// unreachable!();
|
/// unreachable!();
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue