diff options
| author | Josh Stone <jistone@redhat.com> | 2019-07-11 12:57:25 -0700 |
|---|---|---|
| committer | Josh Stone <jistone@redhat.com> | 2019-08-12 15:03:44 -0700 |
| commit | 7539fc69d5b75f35d97fe98ba02b8a52f5617088 (patch) | |
| tree | b2b33f6f583a6a13925fcdb297a4febdbd32437c | |
| parent | 0e300e4380d8fab32b39909ee706aec3e9dbde3b (diff) | |
| download | rust-7539fc69d5b75f35d97fe98ba02b8a52f5617088.tar.gz rust-7539fc69d5b75f35d97fe98ba02b8a52f5617088.zip | |
Reduce genericity in Iterator::last
| -rw-r--r-- | src/libcore/iter/traits/iterator.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/iter/traits/iterator.rs b/src/libcore/iter/traits/iterator.rs index 955d643fb69..d644787d2c4 100644 --- a/src/libcore/iter/traits/iterator.rs +++ b/src/libcore/iter/traits/iterator.rs @@ -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. |
