Skip to content

Commit a2b6aa0

Browse files
committed
API: Deprecate .step() in favour of std .step_by()
1 parent 554fd14 commit a2b6aa0

File tree

5 files changed

+17
-0
lines changed

5 files changed

+17
-0
lines changed

src/adaptors/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,7 @@ impl<B, F, I> Iterator for Batching<I, F>
410410
/// See [`.step()`](../trait.Itertools.html#method.step) for more information.
411411
#[derive(Clone, Debug)]
412412
#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]
413+
#[deprecated(note="Use std .step_by() instead", since="0.8")]
413414
pub struct Step<I> {
414415
iter: Fuse<I>,
415416
skip: usize,
@@ -418,6 +419,7 @@ pub struct Step<I> {
418419
/// Create a `Step` iterator.
419420
///
420421
/// **Panics** if the step is 0.
422+
#[allow(deprecated)]
421423
pub fn step<I>(iter: I, step: usize) -> Step<I>
422424
where I: Iterator
423425
{
@@ -428,6 +430,7 @@ pub fn step<I>(iter: I, step: usize) -> Step<I>
428430
}
429431
}
430432

433+
#[allow(deprecated)]
431434
impl<I> Iterator for Step<I>
432435
where I: Iterator
433436
{
@@ -455,6 +458,7 @@ impl<I> Iterator for Step<I>
455458
}
456459

457460
// known size
461+
#[allow(deprecated)]
458462
impl<I> ExactSizeIterator for Step<I>
459463
where I: ExactSizeIterator
460464
{}

src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ pub use std::iter as __std_iter;
5454

5555
/// The concrete iterator types.
5656
pub mod structs {
57+
#[allow(deprecated)]
5758
pub use adaptors::{
5859
Dedup,
5960
Interleave,
@@ -632,6 +633,8 @@ pub trait Itertools : Iterator {
632633
/// let it = (0..8).step(3);
633634
/// itertools::assert_equal(it, vec![0, 3, 6]);
634635
/// ```
636+
#[deprecated(note="Use std .step_by() instead", since="0.8")]
637+
#[allow(deprecated)]
635638
fn step(self, n: usize) -> Step<Self>
636639
where Self: Sized
637640
{

tests/quick.rs

+6
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ quickcheck! {
403403
assert_eq!(answer.into_iter().last(), a.clone().multi_cartesian_product().last());
404404
}
405405

406+
#[allow(deprecated)]
406407
fn size_step(a: Iter<i16, Exact>, s: usize) -> bool {
407408
let mut s = s;
408409
if s == 0 {
@@ -412,6 +413,8 @@ quickcheck! {
412413
correct_size_hint(filt.step(s)) &&
413414
exact_size(a.step(s))
414415
}
416+
417+
#[allow(deprecated)]
415418
fn equal_step(a: Iter<i16>, s: usize) -> bool {
416419
let mut s = s;
417420
if s == 0 {
@@ -424,6 +427,8 @@ quickcheck! {
424427
keep
425428
}))
426429
}
430+
431+
#[allow(deprecated)]
427432
fn equal_step_vec(a: Vec<i16>, s: usize) -> bool {
428433
let mut s = s;
429434
if s == 0 {
@@ -988,6 +993,7 @@ quickcheck! {
988993
}
989994

990995
quickcheck! {
996+
#[allow(deprecated)]
991997
fn tree_fold1_f64(mut a: Vec<f64>) -> TestResult {
992998
fn collapse_adjacent<F>(x: Vec<f64>, mut f: F) -> Vec<f64>
993999
where F: FnMut(f64, f64) -> f64

tests/test_core.rs

+2
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@ fn test_put_back() {
160160
it::assert_equal(pb, xs.iter().cloned());
161161
}
162162

163+
#[allow(deprecated)]
163164
#[test]
164165
fn step() {
165166
it::assert_equal((0..10).step(1), 0..10);
166167
it::assert_equal((0..10).step(2), (0..10).filter(|x: &i32| *x % 2 == 0));
167168
it::assert_equal((0..10).step(10), 0..1);
168169
}
169170

171+
#[allow(deprecated)]
170172
#[test]
171173
fn merge() {
172174
it::assert_equal((0..10).step(2).merge((1..10).step(2)), 0..10);

tests/test_std.rs

+2
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,15 @@ fn merge_by_btree() {
221221
it::assert_equal(results, expected.into_iter());
222222
}
223223

224+
#[allow(deprecated)]
224225
#[test]
225226
fn kmerge() {
226227
let its = (0..4).map(|s| (s..10).step(4));
227228

228229
it::assert_equal(its.kmerge(), 0..10);
229230
}
230231

232+
#[allow(deprecated)]
231233
#[test]
232234
fn kmerge_2() {
233235
let its = vec![3, 2, 1, 0].into_iter().map(|s| (s..10).step(4));

0 commit comments

Comments
 (0)