summary refs log tree commit diff
path: root/src/libstd/vec.rs
diff options
context:
space:
mode:
authorKevin Ballard <kevin@sb.org>2013-12-09 14:45:53 -0800
committerKevin Ballard <kevin@sb.org>2013-12-29 13:27:59 -0500
commit01209f1e3aed4cd0960fe81dd1d1470650ae8b85 (patch)
treec24728d17fbfd1e9c90f61e6585f411b46750fb8 /src/libstd/vec.rs
parentaa5d779a3590b1ed1559e0489138040a71ae688b (diff)
downloadrust-01209f1e3aed4cd0960fe81dd1d1470650ae8b85.tar.gz
rust-01209f1e3aed4cd0960fe81dd1d1470650ae8b85.zip
Add method .as_mut_slice() to MutableVector
This method is primarily intended to allow for converting a [T, ..N] to
a &mut [T].
Diffstat (limited to 'src/libstd/vec.rs')
-rw-r--r--src/libstd/vec.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs
index 9662a610810..450cf1a4ef2 100644
--- a/src/libstd/vec.rs
+++ b/src/libstd/vec.rs
@@ -2069,6 +2069,10 @@ fn merge_sort<T>(v: &mut [T], compare: |&T, &T| -> Ordering) {
 /// Extension methods for vectors such that their elements are
 /// mutable.
 pub trait MutableVector<'a, T> {
+    /// Work with `self` as a mut slice.
+    /// Primarily intended for getting a &mut [T] from a [T, ..N].
+    fn as_mut_slice(self) -> &'a mut [T];
+
     /// Return a slice that points into another slice.
     fn mut_slice(self, start: uint, end: uint) -> &'a mut [T];
 
@@ -2302,6 +2306,8 @@ pub trait MutableVector<'a, T> {
 
 impl<'a,T> MutableVector<'a, T> for &'a mut [T] {
     #[inline]
+    fn as_mut_slice(self) -> &'a mut [T] { self }
+
     fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] {
         assert!(start <= end);
         assert!(end <= self.len());