Skip to content

Commit c9f2055

Browse files
accumulate into vector and assert, instead of printing
I'm only making this change in one place so that people can express their preferences for this stylistic change. If/when this change is approved I'll go ahead and translate the rest of the `std::ops` examples.
1 parent 11f8805 commit c9f2055

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

src/libcore/iter/range.rs

+2-15
Original file line numberDiff line numberDiff line change
@@ -295,20 +295,8 @@ impl<A: Step> ops::Range<A> {
295295
///
296296
/// ```
297297
/// #![feature(step_by)]
298-
///
299-
/// for i in (0..10).step_by(2) {
300-
/// println!("{}", i);
301-
/// }
302-
/// ```
303-
///
304-
/// This prints:
305-
///
306-
/// ```text
307-
/// 0
308-
/// 2
309-
/// 4
310-
/// 6
311-
/// 8
298+
/// let result: Vec<_> = (0..10).step_by(2).take(10).collect();
299+
/// assert_eq!(result, vec![0, 2, 4, 6, 8]);
312300
/// ```
313301
#[unstable(feature = "step_by", reason = "recent addition",
314302
issue = "27741")]
@@ -650,4 +638,3 @@ impl<A: Step> DoubleEndedIterator for ops::RangeInclusive<A> where
650638
n
651639
}
652640
}
653-

0 commit comments

Comments
 (0)