Skip to content

Commit

Permalink
Rollup merge of rust-lang#35758 - matthew-piziak:vec-assert-over-prin…
Browse files Browse the repository at this point in the history
…tln-remaining, r=GuillaumeGomez

accumulate vector and assert for RangeFrom and RangeInclusive examples

PR rust-lang#35695 for `Range` was merged, so it seems that this side-effect-free style is preferred for Range* examples. This PR performs the same translation for `RangeFrom` and `RangeInclusive`. It also removes what looks to be an erroneously commented line for `#![feature(step_by)]`, and an unnecessary primitive-type annotation in `0u8..`.
  • Loading branch information
Jonathan Turner authored Aug 19, 2016
2 parents bb03ef1 + 95c53b1 commit 2f9ae0d
Showing 1 changed file with 5 additions and 20 deletions.
25 changes: 5 additions & 20 deletions src/libcore/iter/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,11 @@ impl<A: Step> ops::RangeFrom<A> {
/// # Examples
///
/// ```
/// # #![feature(step_by)]
/// #![feature(step_by)]
///
/// for i in (0u8..).step_by(2).take(10) {
/// println!("{}", i);
/// }
/// let result: Vec<_> = (0..).step_by(2).take(5).collect();
/// assert_eq!(result, vec![0, 2, 4, 6, 8]);
/// ```
///
/// 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> {
Expand Down Expand Up @@ -319,20 +316,8 @@ impl<A: Step> ops::RangeInclusive<A> {
/// ```
/// #![feature(step_by, inclusive_range_syntax)]
///
/// for i in (0...10).step_by(2) {
/// println!("{}", i);
/// }
/// ```
///
/// This prints:
///
/// ```text
/// 0
/// 2
/// 4
/// 6
/// 8
/// 10
/// let result: Vec<_> = (0...10).step_by(2).collect();
/// assert_eq!(result, vec![0, 2, 4, 6, 8, 10]);
/// ```
#[unstable(feature = "step_by", reason = "recent addition",
issue = "27741")]
Expand Down

0 comments on commit 2f9ae0d

Please sign in to comment.