about summary refs log tree commit diff
path: root/src/liballoc/vec.rs
diff options
context:
space:
mode:
authorKyle Huey <khuey@kylehuey.com>2019-04-19 21:13:37 -0700
committerKyle Huey <khuey@kylehuey.com>2019-04-19 21:52:43 -0700
commit3e86cf36b5114f201868bf459934fe346a76a2d4 (patch)
tree60a7de7db6b5733586c144a3dfe113c1fc70dfcd /src/liballoc/vec.rs
parent8aaae4294b16b8070a52b858364f440873bfc95c (diff)
downloadrust-3e86cf36b5114f201868bf459934fe346a76a2d4.tar.gz
rust-3e86cf36b5114f201868bf459934fe346a76a2d4.zip
Add implementations of last in terms of next_back on a bunch of DoubleEndedIterators.
r?Manishearth
Diffstat (limited to 'src/liballoc/vec.rs')
-rw-r--r--src/liballoc/vec.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index cd62c3e0524..50bb37b6ed2 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -2385,6 +2385,11 @@ impl<T> Iterator for IntoIter<T> {
     fn count(self) -> usize {
         self.len()
     }
+
+    #[inline]
+    fn last(mut self) -> Option<T> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -2504,6 +2509,11 @@ impl<T> Iterator for Drain<'_, T> {
     fn size_hint(&self) -> (usize, Option<usize>) {
         self.iter.size_hint()
     }
+
+    #[inline]
+    fn last(mut self) -> Option<T> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "drain", since = "1.6.0")]
@@ -2573,6 +2583,10 @@ impl<I: Iterator> Iterator for Splice<'_, I> {
     fn size_hint(&self) -> (usize, Option<usize>) {
         self.drain.size_hint()
     }
+
+    fn last(mut self) -> Option<Self::Item> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "vec_splice", since = "1.21.0")]