From 56a2e5dc22bfd0791b5e71dc89dde48fd3034e03 Mon Sep 17 00:00:00 2001 From: Junyoung Cho Date: Mon, 27 May 2013 10:40:07 +0900 Subject: [PATCH] core::vec is missing methods for mutable slices --- src/libstd/vec.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index 103489988a3..60fc9c07f3b 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -2347,12 +2347,19 @@ impl OwnedEqVector for ~[T] { } } -pub trait MutableVector { +pub trait MutableVector<'self, T> { + fn mut_slice(&mut self, start: uint, end: uint) -> &'self mut [T]; + unsafe fn unsafe_mut_ref(&self, index: uint) -> *mut T; unsafe fn unsafe_set(&self, index: uint, val: T); } -impl<'self,T> MutableVector for &'self mut [T] { +impl<'self,T> MutableVector<'self, T> for &'self mut [T] { + #[inline] + fn mut_slice(&mut self, start: uint, end: uint) -> &'self mut [T] { + mut_slice(*self, start, end) + } + #[inline(always)] unsafe fn unsafe_mut_ref(&self, index: uint) -> *mut T { let pair_ptr: &(*mut T, uint) = transmute(self);