Skip to content

Commit 748f826

Browse files
committed
Remove the deprecated StepBy
1 parent 127a671 commit 748f826

File tree

3 files changed

+1
-220
lines changed

3 files changed

+1
-220
lines changed

src/libcore/iter/mod.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -312,12 +312,6 @@ pub use self::iterator::Iterator;
312312
reason = "likely to be replaced by finer-grained traits",
313313
issue = "42168")]
314314
pub use self::range::Step;
315-
#[unstable(feature = "step_by", reason = "recent addition",
316-
issue = "27741")]
317-
#[rustc_deprecated(since = "1.19.0",
318-
reason = "replaced by `iter::StepBy`")]
319-
#[allow(deprecated)]
320-
pub use self::range::StepBy as DeprecatedStepBy;
321315

322316
#[stable(feature = "rust1", since = "1.0.0")]
323317
pub use self::sources::{Repeat, repeat};

src/libcore/iter/range.rs

Lines changed: 0 additions & 213 deletions
Original file line numberDiff line numberDiff line change
@@ -244,219 +244,6 @@ step_impl_signed!(i64);
244244
step_impl_no_between!(u64 i64);
245245
step_impl_no_between!(u128 i128);
246246

247-
/// An adapter for stepping range iterators by a custom amount.
248-
///
249-
/// The resulting iterator handles overflow by stopping. The `A`
250-
/// parameter is the type being iterated over, while `R` is the range
251-
/// type (usually one of `std::ops::{Range, RangeFrom, RangeInclusive}`.
252-
#[derive(Clone, Debug)]
253-
#[unstable(feature = "step_by", reason = "recent addition",
254-
issue = "27741")]
255-
#[rustc_deprecated(since = "1.19.0",
256-
reason = "replaced by `iter::StepBy`")]
257-
#[allow(deprecated)]
258-
pub struct StepBy<A, R> {
259-
step_by: A,
260-
range: R,
261-
}
262-
263-
impl<A: Step> ops::RangeFrom<A> {
264-
/// Creates an iterator starting at the same point, but stepping by
265-
/// the given amount at each iteration.
266-
///
267-
/// # Examples
268-
///
269-
/// ```
270-
/// #![feature(step_by)]
271-
/// fn main() {
272-
/// let result: Vec<_> = (0..).step_by(2).take(5).collect();
273-
/// assert_eq!(result, vec![0, 2, 4, 6, 8]);
274-
/// }
275-
/// ```
276-
#[unstable(feature = "step_by", reason = "recent addition",
277-
issue = "27741")]
278-
#[rustc_deprecated(since = "1.19.0",
279-
reason = "replaced by `Iterator::step_by`")]
280-
#[allow(deprecated)]
281-
pub fn step_by(self, by: A) -> StepBy<A, Self> {
282-
StepBy {
283-
step_by: by,
284-
range: self
285-
}
286-
}
287-
}
288-
289-
impl<A: Step> ops::Range<A> {
290-
/// Creates an iterator with the same range, but stepping by the
291-
/// given amount at each iteration.
292-
///
293-
/// The resulting iterator handles overflow by stopping.
294-
///
295-
/// # Examples
296-
///
297-
/// ```
298-
/// #![feature(step_by)]
299-
/// fn main() {
300-
/// let result: Vec<_> = (0..10).step_by(2).collect();
301-
/// assert_eq!(result, vec![0, 2, 4, 6, 8]);
302-
/// }
303-
/// ```
304-
#[unstable(feature = "step_by", reason = "recent addition",
305-
issue = "27741")]
306-
#[rustc_deprecated(since = "1.19.0",
307-
reason = "replaced by `Iterator::step_by`")]
308-
#[allow(deprecated)]
309-
pub fn step_by(self, by: A) -> StepBy<A, Self> {
310-
StepBy {
311-
step_by: by,
312-
range: self
313-
}
314-
}
315-
}
316-
317-
impl<A: Step> ops::RangeInclusive<A> {
318-
/// Creates an iterator with the same range, but stepping by the
319-
/// given amount at each iteration.
320-
///
321-
/// The resulting iterator handles overflow by stopping.
322-
///
323-
/// # Examples
324-
///
325-
/// ```
326-
/// #![feature(step_by, inclusive_range_syntax)]
327-
///
328-
/// let result: Vec<_> = (0...10).step_by(2).collect();
329-
/// assert_eq!(result, vec![0, 2, 4, 6, 8, 10]);
330-
/// ```
331-
#[unstable(feature = "step_by", reason = "recent addition",
332-
issue = "27741")]
333-
#[rustc_deprecated(since = "1.19.0",
334-
reason = "replaced by `Iterator::step_by`")]
335-
#[allow(deprecated)]
336-
pub fn step_by(self, by: A) -> StepBy<A, Self> {
337-
StepBy {
338-
step_by: by,
339-
range: self
340-
}
341-
}
342-
}
343-
344-
#[unstable(feature = "step_by", reason = "recent addition",
345-
issue = "27741")]
346-
#[allow(deprecated)]
347-
impl<A> Iterator for StepBy<A, ops::RangeFrom<A>> where
348-
A: Clone,
349-
for<'a> &'a A: Add<&'a A, Output = A>
350-
{
351-
type Item = A;
352-
353-
#[inline]
354-
fn next(&mut self) -> Option<A> {
355-
let mut n = &self.range.start + &self.step_by;
356-
mem::swap(&mut n, &mut self.range.start);
357-
Some(n)
358-
}
359-
360-
#[inline]
361-
fn size_hint(&self) -> (usize, Option<usize>) {
362-
(usize::MAX, None) // Too bad we can't specify an infinite lower bound
363-
}
364-
}
365-
366-
#[unstable(feature = "fused", issue = "35602")]
367-
#[allow(deprecated)]
368-
impl<A> FusedIterator for StepBy<A, ops::RangeFrom<A>>
369-
where A: Clone, for<'a> &'a A: Add<&'a A, Output = A> {}
370-
371-
#[unstable(feature = "step_by", reason = "recent addition",
372-
issue = "27741")]
373-
#[allow(deprecated)]
374-
impl<A: Step + Clone> Iterator for StepBy<A, ops::Range<A>> {
375-
type Item = A;
376-
377-
#[inline]
378-
fn next(&mut self) -> Option<A> {
379-
let rev = self.step_by.is_negative();
380-
if (rev && self.range.start > self.range.end) ||
381-
(!rev && self.range.start < self.range.end)
382-
{
383-
match self.range.start.step(&self.step_by) {
384-
Some(mut n) => {
385-
mem::swap(&mut self.range.start, &mut n);
386-
Some(n)
387-
},
388-
None => {
389-
let mut n = self.range.end.clone();
390-
mem::swap(&mut self.range.start, &mut n);
391-
Some(n)
392-
}
393-
}
394-
} else {
395-
None
396-
}
397-
}
398-
399-
#[inline]
400-
fn size_hint(&self) -> (usize, Option<usize>) {
401-
match Step::steps_between(&self.range.start,
402-
&self.range.end,
403-
&self.step_by) {
404-
Some(hint) => (hint, Some(hint)),
405-
None => (0, None)
406-
}
407-
}
408-
}
409-
410-
#[unstable(feature = "fused", issue = "35602")]
411-
#[allow(deprecated)]
412-
impl<A: Step + Clone> FusedIterator for StepBy<A, ops::Range<A>> {}
413-
414-
#[unstable(feature = "inclusive_range",
415-
reason = "recently added, follows RFC",
416-
issue = "28237")]
417-
#[allow(deprecated)]
418-
impl<A: Step + Clone> Iterator for StepBy<A, ops::RangeInclusive<A>> {
419-
type Item = A;
420-
421-
#[inline]
422-
fn next(&mut self) -> Option<A> {
423-
let rev = self.step_by.is_negative();
424-
425-
if (rev && self.range.start >= self.range.end) ||
426-
(!rev && self.range.start <= self.range.end)
427-
{
428-
match self.range.start.step(&self.step_by) {
429-
Some(n) => {
430-
Some(mem::replace(&mut self.range.start, n))
431-
},
432-
None => {
433-
let last = self.range.start.replace_one();
434-
self.range.end.replace_zero();
435-
self.step_by.replace_one();
436-
Some(last)
437-
},
438-
}
439-
}
440-
else {
441-
None
442-
}
443-
}
444-
445-
#[inline]
446-
fn size_hint(&self) -> (usize, Option<usize>) {
447-
match Step::steps_between(&self.range.start,
448-
&self.range.end,
449-
&self.step_by) {
450-
Some(hint) => (hint.saturating_add(1), hint.checked_add(1)),
451-
None => (0, None)
452-
}
453-
}
454-
}
455-
456-
#[unstable(feature = "fused", issue = "35602")]
457-
#[allow(deprecated)]
458-
impl<A: Step + Clone> FusedIterator for StepBy<A, ops::RangeInclusive<A>> {}
459-
460247
macro_rules! range_exact_iter_impl {
461248
($($t:ty)*) => ($(
462249
#[stable(feature = "rust1", since = "1.0.0")]

src/librand/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
issue = "27703")]
3232
#![feature(core_intrinsics)]
3333
#![feature(staged_api)]
34-
#![feature(step_by)]
34+
#![feature(iterator_step_by)]
3535
#![feature(custom_attribute)]
3636
#![feature(specialization)]
3737
#![allow(unused_attributes)]

0 commit comments

Comments
 (0)