Reduce genericity in Iterator::last

This commit is contained in:
Josh Stone 2019-07-11 12:57:25 -07:00
parent 0e300e4380
commit 7539fc69d5

View File

@ -267,7 +267,12 @@ fn add1<T>(count: usize, _: T) -> usize {
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
fn last(self) -> Option<Self::Item> where Self: Sized {
self.fold(None, |_, x| Some(x))
#[inline]
fn some<T>(_: Option<T>, x: T) -> Option<T> {
Some(x)
}
self.fold(None, some)
}
/// Returns the `n`th element of the iterator.