Skip to content

Commit 7539fc6

Browse files
committed
Reduce genericity in Iterator::last
1 parent 0e300e4 commit 7539fc6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/libcore/iter/traits/iterator.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,12 @@ pub trait Iterator {
267267
#[inline]
268268
#[stable(feature = "rust1", since = "1.0.0")]
269269
fn last(self) -> Option<Self::Item> where Self: Sized {
270-
self.fold(None, |_, x| Some(x))
270+
#[inline]
271+
fn some<T>(_: Option<T>, x: T) -> Option<T> {
272+
Some(x)
273+
}
274+
275+
self.fold(None, some)
271276
}
272277

273278
/// Returns the `n`th element of the iterator.

0 commit comments

Comments
 (0)