Skip to content

Commit f01cbaa

Browse files
committedNov 27, 2014
Fix example code for unreachable!
The previous code was giving an incorrect result (not x/3).
1 parent 82fc1aa commit f01cbaa

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed
 

‎src/libstd/macros.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,11 @@ macro_rules! debug_assert_eq(
217217
/// Iterators:
218218
///
219219
/// ```rust
220-
/// fn divide_by_three(x: i32) -> i32 { // one of the poorest implementations of x/3
221-
/// for i in std::iter::count(0_i32, 1) {
222-
/// if i < 0 { panic!("i32 overflow"); }
223-
/// if x < 3*i { return i; }
220+
/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
221+
/// for i in std::iter::count(0_u32, 1) {
222+
/// if 3*i < i { panic!("u32 overflow"); }
223+
/// if x < 3*i { return i-1; }
224224
/// }
225-
///
226225
/// unreachable!();
227226
/// }
228227
/// ```

5 commit comments

Comments
 (5)

bors commented on Nov 28, 2014

@bors
Collaborator

saw approval from Gankro
at olivren@f01cbaa

bors commented on Nov 28, 2014

@bors
Collaborator

merging olivren/rust/master = f01cbaa into auto

bors commented on Nov 28, 2014

@bors
Collaborator

olivren/rust/master = f01cbaa merged ok, testing candidate = 832dc61

bors commented on Nov 28, 2014

@bors
Collaborator

fast-forwarding master to auto = 832dc61

Please sign in to comment.