about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2019-07-11 12:57:25 -0700
committerJosh Stone <jistone@redhat.com>2019-08-12 15:03:44 -0700
commit7539fc69d5b75f35d97fe98ba02b8a52f5617088 (patch)
treeb2b33f6f583a6a13925fcdb297a4febdbd32437c
parent0e300e4380d8fab32b39909ee706aec3e9dbde3b (diff)
downloadrust-7539fc69d5b75f35d97fe98ba02b8a52f5617088.tar.gz
rust-7539fc69d5b75f35d97fe98ba02b8a52f5617088.zip
Reduce genericity in Iterator::last
-rw-r--r--src/libcore/iter/traits/iterator.rs7
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.