about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorDaniel Micay <danielmicay@gmail.com>2013-07-26 20:48:56 -0400
committerDaniel Micay <danielmicay@gmail.com>2013-07-27 14:36:52 -0400
commitd7c9bb4b688ff20a3fd1d4ff1a11bb4dcbdc2c47 (patch)
treef4f1ad8b56c847e657ebb1efea65f8e026f23073 /src/libstd
parentd6bc438bbcb9240d0303ffec81bf1a617f0903a5 (diff)
downloadrust-d7c9bb4b688ff20a3fd1d4ff1a11bb4dcbdc2c47.tar.gz
rust-d7c9bb4b688ff20a3fd1d4ff1a11bb4dcbdc2c47.zip
vec: add mut_slice_{to,from}
Closes #8066
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/vec.rs23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 87ac4037e8e..8dbae43689d 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -1656,6 +1656,8 @@ impl<T:Eq> OwnedEqVector<T> for ~[T] {
 #[allow(missing_doc)]
 pub trait MutableVector<'self, T> {
     fn mut_slice(self, start: uint, end: uint) -> &'self mut [T];
+    fn mut_slice_from(self, start: uint) -> &'self mut [T];
+    fn mut_slice_to(self, end: uint) -> &'self mut [T];
     fn mut_iter(self) -> VecMutIterator<'self, T>;
     fn mut_rev_iter(self) -> VecMutRevIterator<'self, T>;
 
@@ -1709,6 +1711,27 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] {
         }
     }
 
+    /**
+     * Returns a slice of self from `start` to the end of the vec.
+     *
+     * Fails when `start` points outside the bounds of self.
+     */
+    #[inline]
+    fn mut_slice_from(self, start: uint) -> &'self mut [T] {
+        let len = self.len();
+        self.mut_slice(start, len)
+    }
+
+    /**
+     * Returns a slice of self from the start of the vec to `end`.
+     *
+     * Fails when `end` points outside the bounds of self.
+     */
+    #[inline]
+    fn mut_slice_to(self, end: uint) -> &'self mut [T] {
+        self.mut_slice(0, end)
+    }
+
     #[inline]
     fn mut_split(self, mid: uint) -> (&'self mut [T], &'self mut [T]) {
         unsafe {