From c9f20551103cfbe51bdd859f5eb3554f7bed72e8 Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Mon, 15 Aug 2016 18:03:11 -0400 Subject: [PATCH 1/2] 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. --- src/libcore/iter/range.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index c234ef21db6d1..c4b0794d1e898 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -295,20 +295,8 @@ impl ops::Range { /// /// ``` /// #![feature(step_by)] - /// - /// for i in (0..10).step_by(2) { - /// println!("{}", i); - /// } - /// ``` - /// - /// This prints: - /// - /// ```text - /// 0 - /// 2 - /// 4 - /// 6 - /// 8 + /// let result: Vec<_> = (0..10).step_by(2).take(10).collect(); + /// assert_eq!(result, vec![0, 2, 4, 6, 8]); /// ``` #[unstable(feature = "step_by", reason = "recent addition", issue = "27741")] @@ -650,4 +638,3 @@ impl DoubleEndedIterator for ops::RangeInclusive where n } } - From 2c9a1d9c4aca14ddca4a9b6bd4631b04ade43497 Mon Sep 17 00:00:00 2001 From: Matthew Piziak Date: Mon, 15 Aug 2016 18:30:25 -0400 Subject: [PATCH 2/2] remove `.take(10)` from `Range` example --- src/libcore/iter/range.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/iter/range.rs b/src/libcore/iter/range.rs index c4b0794d1e898..079dfe2a81f80 100644 --- a/src/libcore/iter/range.rs +++ b/src/libcore/iter/range.rs @@ -295,7 +295,7 @@ impl ops::Range { /// /// ``` /// #![feature(step_by)] - /// let result: Vec<_> = (0..10).step_by(2).take(10).collect(); + /// let result: Vec<_> = (0..10).step_by(2).collect(); /// assert_eq!(result, vec![0, 2, 4, 6, 8]); /// ``` #[unstable(feature = "step_by", reason = "recent addition",