about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-12-30 01:41:55 -0800
committerbors <bors@rust-lang.org>2013-12-30 01:41:55 -0800
commit28a091fc7c7e23eee346d87fd34ea1546002ee2c (patch)
tree5c11ddb90ba5a775c1527cbe6b3094944589043c /src/libstd
parentadc5eefa231d98273214c47ecff9dcb2fbe37460 (diff)
parent01209f1e3aed4cd0960fe81dd1d1470650ae8b85 (diff)
downloadrust-28a091fc7c7e23eee346d87fd34ea1546002ee2c.tar.gz
rust-28a091fc7c7e23eee346d87fd34ea1546002ee2c.zip
auto merge of #10885 : kballard/rust/as_mut_slice, r=cmr
This method is primarily intended to allow for converting a [T, ..N] to
a &mut [T].
Diffstat (limited to 'src/libstd')
-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());