Skip to content

Commit 8e064d1

Browse files
committed
API: Deprecate .foreach() in favour of std's .for_each()
1 parent a2b6aa0 commit 8e064d1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1362,11 +1362,12 @@ pub trait Itertools : Iterator {
13621362
///
13631363
/// itertools::assert_equal(rx.iter(), vec![1, 3, 5, 7, 9]);
13641364
/// ```
1365-
fn foreach<F>(self, mut f: F)
1365+
#[deprecated(note="Use .for_each() instead", since="0.8")]
1366+
fn foreach<F>(self, f: F)
13661367
where F: FnMut(Self::Item),
13671368
Self: Sized,
13681369
{
1369-
self.fold((), move |(), element| f(element))
1370+
self.for_each(f)
13701371
}
13711372

13721373
/// Combine all an iterator's elements into one element by using `Extend`.

tests/test_core.rs

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ fn test_interleave() {
114114
it::assert_equal(it, rs.iter());
115115
}
116116

117+
#[allow(deprecated)]
117118
#[test]
118119
fn foreach() {
119120
let xs = [1i32, 2, 3];

0 commit comments

Comments
 (0)