Reduce genericity in Iterator::last
This commit is contained in:
parent
0e300e4380
commit
7539fc69d5
1 changed files with 6 additions and 1 deletions
|
|
@ -267,7 +267,12 @@ pub trait Iterator {
|
|||
#[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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue