rename MutableVector::mut_split(at) to MutableVector::mut_split_at(at)

This commit is contained in:
Guillaume Pinot 2013-12-01 18:19:39 +01:00
parent 61443dc1f5
commit 25bb1a406c
3 changed files with 11 additions and 11 deletions

View file

@ -207,14 +207,14 @@ impl<T> RingBuf<T> {
// start_index to self.elts.len()
// and then
// 0 to end_index
let (temp, remaining1) = self.elts.mut_split(start_index);
let (remaining2, _) = temp.mut_split(end_index);
let (temp, remaining1) = self.elts.mut_split_at(start_index);
let (remaining2, _) = temp.mut_split_at(end_index);
RingBufMutIterator { remaining1: remaining1,
remaining2: remaining2,
nelts: self.nelts }
} else {
// Items to iterate goes from start_index to end_index:
let (empty, elts) = self.elts.mut_split(0);
let (empty, elts) = self.elts.mut_split_at(0);
let remaining1 = elts.mut_slice(start_index, end_index);
RingBufMutIterator { remaining1: remaining1,
remaining2: empty,

View file

@ -666,8 +666,8 @@ The current rules could use some correction:
function will fail to compile:
fn mut_shift_ref<'a,T>(x: &mut &'a mut [T]) -> &'a mut T {
// `mut_split` will restrict mutation against *x:
let (head, tail) = (*x).mut_split(1);
// `mut_split_at` will restrict mutation against *x:
let (head, tail) = (*x).mut_split_at(1);
// Hence mutating `*x` yields an error here:
*x = tail;

View file

@ -1995,7 +1995,7 @@ pub trait MutableVector<'self, T> {
* itself) and the second will contain all indices from
* `mid..len` (excluding the index `len` itself).
*/
fn mut_split(self, mid: uint) -> (&'self mut [T],
fn mut_split_at(self, mid: uint) -> (&'self mut [T],
&'self mut [T]);
/// Reverse the order of elements in a vector, in place
@ -2052,7 +2052,7 @@ impl<'self,T> MutableVector<'self, T> for &'self mut [T] {
}
#[inline]
fn mut_split(self, mid: uint) -> (&'self mut [T], &'self mut [T]) {
fn mut_split_at(self, mid: uint) -> (&'self mut [T], &'self mut [T]) {
unsafe {
let len = self.len();
let self2: &'self mut [T] = cast::transmute_copy(&self);
@ -2592,7 +2592,7 @@ impl<'self, T> Iterator<&'self mut [T]> for MutChunkIter<'self, T> {
} else {
let sz = cmp::min(self.remaining, self.chunk_size);
let tmp = util::replace(&mut self.v, &mut []);
let (head, tail) = tmp.mut_split(sz);
let (head, tail) = tmp.mut_split_at(sz);
self.v = tail;
self.remaining -= sz;
Some(head)
@ -2620,7 +2620,7 @@ impl<'self, T> DoubleEndedIterator<&'self mut [T]> for MutChunkIter<'self, T> {
let remainder = self.remaining % self.chunk_size;
let sz = if remainder != 0 { remainder } else { self.chunk_size };
let tmp = util::replace(&mut self.v, &mut []);
let (head, tail) = tmp.mut_split(self.remaining - sz);
let (head, tail) = tmp.mut_split_at(self.remaining - sz);
self.v = head;
self.remaining -= sz;
Some(tail)
@ -3898,10 +3898,10 @@ mod tests {
}
#[test]
fn test_mut_split() {
fn test_mut_split_at() {
let mut values = [1u8,2,3,4,5];
{
let (left, right) = values.mut_split(2);
let (left, right) = values.mut_split_at(2);
assert_eq!(left.slice(0, left.len()), [1, 2]);
for p in left.mut_iter() {
*p += 1;