Skip to content

Commit fe8efae

Browse files
Remove deprecated Itertools::foreach
1 parent 30de5a8 commit fe8efae

File tree

3 files changed

+1
-38
lines changed

3 files changed

+1
-38
lines changed

src/lib.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,32 +2149,6 @@ pub trait Itertools: Iterator {
21492149
self
21502150
}
21512151

2152-
/// Run the closure `f` eagerly on each element of the iterator.
2153-
///
2154-
/// Consumes the iterator until its end.
2155-
///
2156-
/// ```
2157-
/// use std::sync::mpsc::channel;
2158-
/// use itertools::Itertools;
2159-
///
2160-
/// let (tx, rx) = channel();
2161-
///
2162-
/// // use .foreach() to apply a function to each value -- sending it
2163-
/// (0..5).map(|x| x * 2 + 1).foreach(|x| { tx.send(x).unwrap(); } );
2164-
///
2165-
/// drop(tx);
2166-
///
2167-
/// itertools::assert_equal(rx.iter(), vec![1, 3, 5, 7, 9]);
2168-
/// ```
2169-
#[deprecated(note = "Use .for_each() instead", since = "0.8.0")]
2170-
fn foreach<F>(self, f: F)
2171-
where
2172-
F: FnMut(Self::Item),
2173-
Self: Sized,
2174-
{
2175-
self.for_each(f);
2176-
}
2177-
21782152
/// Combine all an iterator's elements into one element by using [`Extend`].
21792153
///
21802154
/// This combinator will extend the first item with each of the rest of the

tests/test_core.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,6 @@ fn test_intersperse_with() {
172172
it::assert_equal(it, ys.iter());
173173
}
174174

175-
#[allow(deprecated)]
176-
#[test]
177-
fn foreach() {
178-
let xs = [1i32, 2, 3];
179-
let mut sum = 0;
180-
xs.iter().foreach(|elt| sum += *elt);
181-
assert!(sum == 6);
182-
}
183-
184175
#[test]
185176
fn dropping() {
186177
let xs = [1, 2, 3];

tests/test_std.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,6 @@ fn test_rciter() {
360360
assert_eq!(z.next(), Some((0, 1)));
361361
}
362362

363-
#[allow(deprecated)]
364363
#[test]
365364
fn trait_pointers() {
366365
struct ByRef<'r, I: ?Sized>(&'r mut I);
@@ -379,7 +378,6 @@ fn trait_pointers() {
379378
assert_eq!(it.next(), Some(0));
380379

381380
{
382-
/* make sure foreach works on non-Sized */
383381
let jt: &mut dyn Iterator<Item = i32> = &mut *it;
384382
assert_eq!(jt.next(), Some(1));
385383

@@ -389,7 +387,7 @@ fn trait_pointers() {
389387
}
390388

391389
assert_eq!(jt.find_position(|x| *x == 4), Some((1, 4)));
392-
jt.foreach(|_| ());
390+
jt.for_each(|_| ());
393391
}
394392
}
395393

0 commit comments

Comments
 (0)