diff options
| author | Simon Sapin <simon.sapin@exyr.org> | 2016-01-25 00:56:34 +0100 |
|---|---|---|
| committer | Simon Sapin <simon.sapin@exyr.org> | 2016-01-26 14:23:38 +0100 |
| commit | 70d4f263ba3d1db40f246ebe600992abb1ac85be (patch) | |
| tree | d26c0bf03e37e2c87649e820d0e142338ed49f00 /src/libcore | |
| parent | 1972c50b9eaab85742c0a6f5ea7eade5eb0d63fc (diff) | |
| download | rust-70d4f263ba3d1db40f246ebe600992abb1ac85be.tar.gz rust-70d4f263ba3d1db40f246ebe600992abb1ac85be.zip | |
RangeFrom::step_by docs: fix example
The previous example did not do what its description said. In it panicked on integer overflow in debug mode, and went into an infinite loop in release mode (wrapping back to 0 after printing 254).
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter.rs | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index ddc4fb32cde..3f1c0f6a549 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -4252,13 +4252,15 @@ impl<A: Step> RangeFrom<A> { /// /// # Examples /// - /// ```ignore - /// for i in (0u8..).step_by(2) { + /// ``` + /// # #![feature(step_by)] + /// + /// for i in (0u8..).step_by(2).take(10) { /// println!("{}", i); /// } /// ``` /// - /// This prints all even `u8` values. + /// This prints the first ten even natural integers (0 to 18). #[unstable(feature = "step_by", reason = "recent addition", issue = "27741")] pub fn step_by(self, by: A) -> StepBy<A, Self> { |
