From 7539fc69d5b75f35d97fe98ba02b8a52f5617088 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 11 Jul 2019 12:57:25 -0700 Subject: [PATCH] Reduce genericity in Iterator::last --- src/libcore/iter/traits/iterator.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 @@ fn add1(count: usize, _: T) -> usize { #[inline] #[stable(feature = "rust1", since = "1.0.0")] fn last(self) -> Option where Self: Sized { - self.fold(None, |_, x| Some(x)) + #[inline] + fn some(_: Option, x: T) -> Option { + Some(x) + } + + self.fold(None, some) } /// Returns the `n`th element of the iterator.