about summary refs log tree commit diff
path: root/src/libcore/slice
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/libcore/slice
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/libcore/slice')
-rw-r--r--src/libcore/slice/mod.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs
index bf3dda48dc7..cda4268607f 100644
--- a/src/libcore/slice/mod.rs
+++ b/src/libcore/slice/mod.rs
@@ -3539,6 +3539,11 @@ impl<'a, T, P> Iterator for Split<'a, T, P> where P: FnMut(&T) -> bool {
             (1, Some(self.v.len() + 1))
         }
     }
+
+    #[inline]
+    fn last(mut self) -> Option<Self::Item> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -3637,6 +3642,11 @@ impl<'a, T, P> Iterator for SplitMut<'a, T, P> where P: FnMut(&T) -> bool {
             (1, Some(self.v.len() + 1))
         }
     }
+
+    #[inline]
+    fn last(mut self) -> Option<Self::Item> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
@@ -3702,6 +3712,11 @@ impl<'a, T, P> Iterator for RSplit<'a, T, P> where P: FnMut(&T) -> bool {
     fn size_hint(&self) -> (usize, Option<usize>) {
         self.inner.size_hint()
     }
+
+    #[inline]
+    fn last(mut self) -> Option<Self::Item> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "slice_rsplit", since = "1.27.0")]
@@ -3766,6 +3781,11 @@ impl<'a, T, P> Iterator for RSplitMut<'a, T, P> where P: FnMut(&T) -> bool {
     fn size_hint(&self) -> (usize, Option<usize>) {
         self.inner.size_hint()
     }
+
+    #[inline]
+    fn last(mut self) -> Option<Self::Item> {
+        self.next_back()
+    }
 }
 
 #[stable(feature = "slice_rsplit", since = "1.27.0")]