Skip to content

Commit 832dc61

Browse files
committed
auto merge of #19360 : olivren/rust/master, r=Gankro
The previous code was giving an incorrect result (not x/3). Also, this function does not work with signed integers. It now accepts `u32` instead of `i32`.
2 parents dbbb722 + f01cbaa commit 832dc61

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
/// ```

0 commit comments

Comments
 (0)