if done { return; }
let missing_patterns =
- props.error_patterns.slice(next_err_idx, props.error_patterns.len());
+ props.error_patterns[next_err_idx..];
if missing_patterns.len() == 1u {
fatal_proc_rec(format!("error pattern '{}' not found!",
missing_patterns[0]).as_slice(),
if start > self.storage.len() {
start = self.storage.len();
}
- let mut iter = self.storage.slice_from(start).iter();
+ let mut iter = self.storage[start..].iter();
MaskWords {
next_word: iter.next(),
iter: iter,
/// *num = *num - 2;
/// }
/// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
- /// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>().as_slice(), b);
+ /// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>()[], b);
/// ```
pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> {
let start_index = raw_index(self.lo, self.elts.len(), 0);
} else {
// Items to iterate goes from start_index to end_index:
let (empty, elts) = self.elts.split_at_mut(0);
- let remaining1 = elts.slice_mut(start_index, end_index);
+ let remaining1 = elts[mut start_index..end_index];
MutItems { remaining1: remaining1,
remaining2: empty,
nelts: self.nelts }
//! These traits include `ImmutableSlice`, which is defined for `&[T]` types,
//! and `MutableSlice`, defined for `&mut [T]` types.
//!
-//! An example is the method `.slice(a, b)` that returns an immutable "view" into
-//! a `Vec` or another slice from the index interval `[a, b)`:
+//! An example is the `slice` method which enables slicing syntax `[a..b]` that
+//! returns an immutable "view" into a `Vec` or another slice from the index
+//! interval `[a, b)`:
//!
//! ```rust
//! let numbers = [0i, 1i, 2i];
-//! let last_numbers = numbers.slice(1, 3);
+//! let last_numbers = numbers[1..3];
//! // last_numbers is now &[1i, 2i]
//! ```
//!
#[inline]
fn move_from(self, mut src: Vec<T>, start: uint, end: uint) -> uint {
- for (a, b) in self.iter_mut().zip(src.slice_mut(start, end).iter_mut()) {
+ for (a, b) in self.iter_mut().zip(src[mut start..end].iter_mut()) {
mem::swap(a, b);
}
cmp::min(self.len(), end-start)
self.swap(j, i-1);
// Step 4: Reverse the (previously) weakly decreasing part
- self.slice_from_mut(i).reverse();
+ self[mut i..].reverse();
true
}
}
// Step 2: Reverse the weakly increasing part
- self.slice_from_mut(i).reverse();
+ self[mut i..].reverse();
// Step 3: Find the rightmost element equal to or bigger than the pivot (i-1)
let mut j = self.len() - 1;
fn test_slice() {
// Test fixed length vector.
let vec_fixed = [1i, 2, 3, 4];
- let v_a = vec_fixed.slice(1u, vec_fixed.len()).to_vec();
+ let v_a = vec_fixed[1u..vec_fixed.len()].to_vec();
assert_eq!(v_a.len(), 3u);
let v_a = v_a.as_slice();
assert_eq!(v_a[0], 2);
assert_eq!(v_a[2], 4);
// Test on stack.
- let vec_stack = &[1i, 2, 3];
- let v_b = vec_stack.slice(1u, 3u).to_vec();
+ let vec_stack: &[_] = &[1i, 2, 3];
+ let v_b = vec_stack[1u..3u].to_vec();
assert_eq!(v_b.len(), 2u);
let v_b = v_b.as_slice();
assert_eq!(v_b[0], 2);
// Test `Box<[T]>`
let vec_unique = vec![1i, 2, 3, 4, 5, 6];
- let v_d = vec_unique.slice(1u, 6u).to_vec();
+ let v_d = vec_unique[1u..6u].to_vec();
assert_eq!(v_d.len(), 5u);
let v_d = v_d.as_slice();
assert_eq!(v_d[0], 2);
#[test]
fn test_slice_from() {
let vec: &[int] = &[1, 2, 3, 4];
- assert_eq!(vec.slice_from(0), vec);
+ assert_eq!(vec[0..], vec);
let b: &[int] = &[3, 4];
- assert_eq!(vec.slice_from(2), b);
+ assert_eq!(vec[2..], b);
let b: &[int] = &[];
- assert_eq!(vec.slice_from(4), b);
+ assert_eq!(vec[4..], b);
}
#[test]
fn test_slice_to() {
let vec: &[int] = &[1, 2, 3, 4];
- assert_eq!(vec.slice_to(4), vec);
+ assert_eq!(vec[..4], vec);
let b: &[int] = &[1, 2];
- assert_eq!(vec.slice_to(2), b);
+ assert_eq!(vec[..2], b);
let b: &[int] = &[];
- assert_eq!(vec.slice_to(0), b);
+ assert_eq!(vec[..0], b);
}
assert!(a == [7i,2,3,4]);
let mut a = [1i,2,3,4,5];
let b = vec![5i,6,7,8,9,0];
- assert_eq!(a.slice_mut(2,4).move_from(b,1,6), 2);
+ assert_eq!(a[mut 2..4].move_from(b,1,6), 2);
assert!(a == [1i,2,6,7,5]);
}
#[test]
fn test_reverse_part() {
let mut values = [1i,2,3,4,5];
- values.slice_mut(1, 4).reverse();
+ values[mut 1..4].reverse();
assert!(values == [1,4,3,2,5]);
}
fn test_bytes_set_memory() {
use slice::bytes::MutableByteVector;
let mut values = [1u8,2,3,4,5];
- values.slice_mut(0,5).set_memory(0xAB);
+ values[mut 0..5].set_memory(0xAB);
assert!(values == [0xAB, 0xAB, 0xAB, 0xAB, 0xAB]);
- values.slice_mut(2,4).set_memory(0xFF);
+ values[mut 2..4].set_memory(0xFF);
assert!(values == [0xAB, 0xAB, 0xFF, 0xFF, 0xAB]);
}
let mut values = [1u8,2,3,4,5];
{
let (left, right) = values.split_at_mut(2);
- assert!(left.slice(0, left.len()) == [1, 2]);
+ {
+ let left: &[_] = left;
+ assert!(left[0..left.len()] == [1, 2]);
+ }
for p in left.iter_mut() {
*p += 1;
}
- assert!(right.slice(0, right.len()) == [3, 4, 5]);
+ {
+ let right: &[_] = right;
+ assert!(right[0..right.len()] == [3, 4, 5]);
+ }
for p in right.iter_mut() {
*p += 2;
}
}
assert_eq!(cnt, 3);
- for f in v.slice(1, 3).iter() {
+ for f in v[1..3].iter() {
assert!(*f == Foo);
cnt += 1;
}
let mut bytes = [0u8, ..4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(bytes).unwrap_or(0);
- let s = ::core::str::from_utf8(bytes.slice_to(len)).unwrap();
+ let s = ::core::str::from_utf8(bytes[..len]).unwrap();
if Some(c) != s.chars().next() {
fail!("character {:x}={} does not decode correctly", c as u32, c);
}
let mut bytes = [0u8, ..4];
for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
let len = c.encode_utf8(bytes).unwrap_or(0);
- let s = ::core::str::from_utf8(bytes.slice_to(len)).unwrap();
+ let s = ::core::str::from_utf8(bytes[..len]).unwrap();
if Some(c) != s.chars().rev().next() {
fail!("character {:x}={} does not decode correctly", c as u32, c);
}
if i > 0 {
unsafe {
- res.as_mut_vec().push_all(v.slice_to(i))
+ res.as_mut_vec().push_all(v.[..i])
};
}
macro_rules! error(() => ({
unsafe {
if subseqidx != i_ {
- res.as_mut_vec().push_all(v.slice(subseqidx, i_));
+ res.as_mut_vec().push_all(vv[subseqidx..i_]);
}
subseqidx = i;
res.as_mut_vec().push_all(REPLACEMENT);
}
if subseqidx < total {
unsafe {
- res.as_mut_vec().push_all(v.slice(subseqidx, total))
+ res.as_mut_vec().push_all(v[subseqidx..total])
};
}
Owned(res.into_string())
use core::fmt::Show;
use core::mem::zeroed;
use core::mem;
+use core::ops::{Slice,SliceMut};
use core::uint;
use core::iter;
use std::hash::{Writer, Hash};
}
};
// push to the stack.
- it.stack[it.length] = children.$slice_from(slice_idx).$iter();
+ it.stack[it.length] = children.$slice_from(&slice_idx).$iter();
it.length += 1;
if ret { return it }
})
fn bound<'a>(&'a self, key: uint, upper: bool) -> Entries<'a, T> {
bound!(Entries, self = self,
key = key, is_upper = upper,
- slice_from = slice_from, iter = iter,
+ slice_from = slice_from_, iter = iter,
mutability = )
}
fn bound_mut<'a>(&'a mut self, key: uint, upper: bool) -> MutEntries<'a, T> {
bound!(MutEntries, self = self,
key = key, is_upper = upper,
- slice_from = slice_from_mut, iter = iter_mut,
+ slice_from = slice_from_mut_, iter = iter_mut,
mutability = mut)
}
// self.len <= other.len due to the truncate above, so the
// slice here is always in-bounds.
- let slice = other.slice_from(self.len());
+ let slice = other[self.len()..];
self.push_all(slice);
}
}
///
/// ```
/// let vec = vec![1i, 2, 3, 4];
- /// assert!(vec.slice(0, 2) == [1, 2]);
+ /// assert!(vec[0..2] == [1, 2]);
/// ```
#[inline]
+ #[deprecated = "use slicing syntax"]
pub fn slice<'a>(&'a self, start: uint, end: uint) -> &'a [T] {
- self.as_slice().slice(start, end)
+ self[start..end]
}
/// Returns a slice containing all but the first element of the vector.
/// ```
#[inline]
pub fn tail<'a>(&'a self) -> &'a [T] {
- self.as_slice().tail()
+ self[].tail()
}
/// Returns all but the first `n' elements of a vector.
/// assert!(vec.tailn(2) == [3, 4]);
/// ```
#[inline]
- #[deprecated = "use slice_from"]
+ #[deprecated = "use slicing syntax"]
pub fn tailn<'a>(&'a self, n: uint) -> &'a [T] {
- self.as_slice().slice_from(n)
+ self[n..]
}
/// Returns a reference to the last element of a vector, or `None` if it is
/// ```
#[inline]
pub fn last<'a>(&'a self) -> Option<&'a T> {
- self.as_slice().last()
+ self[].last()
}
/// Deprecated: use `last_mut`.
}
/// Deprecated: use `slice_mut`.
- #[deprecated = "use slice_mut"]
+ #[deprecated = "use slicing syntax"]
pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint)
-> &'a mut [T] {
- self.slice_mut(start, end)
+ self[mut start..end]
}
/// Returns a mutable slice of `self` between `start` and `end`.
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
- /// assert!(vec.slice_mut(0, 2) == [1, 2]);
+ /// assert!(vec[mut 0..2] == [1, 2]);
/// ```
#[inline]
+ #[deprecated = "use slicing syntax"]
pub fn slice_mut<'a>(&'a mut self, start: uint, end: uint)
-> &'a mut [T] {
- self.as_mut_slice().slice_mut(start, end)
+ self[mut start..end]
}
/// Deprecated: use "slice_from_mut".
- #[deprecated = "use slice_from_mut"]
+ #[deprecated = "use slicing syntax"]
pub fn mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] {
- self.slice_from_mut(start)
+ self[mut start..]
}
/// Returns a mutable slice of `self` from `start` to the end of the `Vec`.
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
- /// assert!(vec.slice_from_mut(2) == [3, 4]);
+ /// assert!(vec[mut 2..] == [3, 4]);
/// ```
#[inline]
+ #[deprecated = "use slicing syntax"]
pub fn slice_from_mut<'a>(&'a mut self, start: uint) -> &'a mut [T] {
- self.as_mut_slice().slice_from_mut(start)
+ self[mut start..]
}
/// Deprecated: use `slice_to_mut`.
- #[deprecated = "use slice_to_mut"]
+ #[deprecated = "use slicing syntax"]
pub fn mut_slice_to<'a>(&'a mut self, end: uint) -> &'a mut [T] {
- self.slice_to_mut(end)
+ self[mut ..end]
}
/// Returns a mutable slice of `self` from the start of the `Vec` to `end`.
///
/// ```
/// let mut vec = vec![1i, 2, 3, 4];
- /// assert!(vec.slice_to_mut(2) == [1, 2]);
+ /// assert!(vec[mut ..2] == [1, 2]);
/// ```
#[inline]
+ #[deprecated = "use slicing syntax"]
pub fn slice_to_mut<'a>(&'a mut self, end: uint) -> &'a mut [T] {
- self.as_mut_slice().slice_to_mut(end)
+ self[mut ..end]
}
/// Deprecated: use `split_at_mut`.
/// ```
#[inline]
pub fn split_at_mut<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) {
- self.as_mut_slice().split_at_mut(mid)
+ self[mut].split_at_mut(mid)
}
/// Reverses the order of elements in a vector, in place.
/// ```
#[inline]
pub fn reverse(&mut self) {
- self.as_mut_slice().reverse()
+ self[mut].reverse()
}
/// Returns a slice of `self` from `start` to the end of the vec.
///
/// ```
/// let vec = vec![1i, 2, 3];
- /// assert!(vec.slice_from(1) == [2, 3]);
+ /// assert!(vec[1..] == [2, 3]);
/// ```
#[inline]
+ #[deprecated = "use slicing syntax"]
pub fn slice_from<'a>(&'a self, start: uint) -> &'a [T] {
- self.as_slice().slice_from(start)
+ self[start..]
}
/// Returns a slice of self from the start of the vec to `end`.
///
/// ```
/// let vec = vec![1i, 2, 3, 4];
- /// assert!(vec.slice_to(2) == [1, 2]);
+ /// assert!(vec[..2] == [1, 2]);
/// ```
#[inline]
+ #[deprecated = "use slicing syntax"]
pub fn slice_to<'a>(&'a self, end: uint) -> &'a [T] {
- self.as_slice().slice_to(end)
+ self[..end]
}
/// Returns a slice containing all but the last element of the vector.
/// ```
#[inline]
pub fn init<'a>(&'a self) -> &'a [T] {
- self.slice(0, self.len() - 1)
+ self[0..self.len() - 1]
}
let mut values = Vec::from_slice([1u8,2,3,4,5]);
{
let (left, right) = values.split_at_mut(2);
- assert!(left.slice(0, left.len()) == [1, 2]);
+ {
+ let left: &[_] = left;
+ assert!(left[0..left.len()] == [1, 2]);
+ }
for p in left.iter_mut() {
*p += 1;
}
- assert!(right.slice(0, right.len()) == [3, 4, 5]);
+ {
+ let right: &[_] = right;
+ assert!(right[0..right.len()] == [3, 4, 5]);
+ }
for p in right.iter_mut() {
*p += 2;
}
use num::{Float, FPNaN, FPInfinite, ToPrimitive, Primitive};
use num::{Zero, One, cast};
use result::Ok;
-use slice::{ImmutableSlice, MutableSlice};
+use slice::MutableSlice;
use slice;
use str::StrSlice;
_ => ()
}
- buf.slice_to_mut(end).reverse();
+ buf[mut ..end].reverse();
// Remember start of the fractional digits.
// Points one beyond end of buf if none get generated,
impl<'a> fmt::FormatWriter for Filler<'a> {
fn write(&mut self, bytes: &[u8]) -> fmt::Result {
- slice::bytes::copy_memory(self.buf.slice_from_mut(*self.end),
+ slice::bytes::copy_memory(self.buf[mut *self.end..],
bytes);
*self.end += bytes.len();
Ok(())
}
}
- f(buf.slice_to(end))
+ f(buf[..end])
}
for c in sign.into_iter() {
let mut b = [0, ..4];
let n = c.encode_utf8(b).unwrap_or(0);
- try!(f.buf.write(b.slice_to(n)));
+ try!(f.buf.write(b[..n]));
}
if prefixed { f.buf.write(prefix.as_bytes()) }
else { Ok(()) }
let len = self.fill.encode_utf8(fill).unwrap_or(0);
for _ in range(0, pre_pad) {
- try!(self.buf.write(fill.slice_to(len)));
+ try!(self.buf.write(fill[..len]));
}
try!(f(self));
for _ in range(0, post_pad) {
- try!(self.buf.write(fill.slice_to(len)));
+ try!(self.buf.write(fill[..len]));
}
Ok(())
let mut utf8 = [0u8, ..4];
let amt = self.encode_utf8(utf8).unwrap_or(0);
- let s: &str = unsafe { mem::transmute(utf8.slice_to(amt)) };
+ let s: &str = unsafe { mem::transmute(utf8[..amt]) };
secret_string(&s, f)
}
}
use fmt;
use iter::DoubleEndedIterator;
use num::{Int, cast, zero};
-use slice::{ImmutableSlice, MutableSlice};
+use slice::{MutableSlice};
/// A type that represents a specific radix
#[doc(hidden)]
if x == zero() { break; } // No more digits left to accumulate.
}
}
- f.pad_integral(is_positive, self.prefix(), buf.slice_from(curr))
+ f.pad_integral(is_positive, self.prefix(), buf[curr..])
}
}
///
/// Slicing with `start` equal to `end` yields an empty slice.
#[unstable = "waiting on final error conventions"]
- fn slice(&self, start: uint, end: uint) -> &'a [T];
+ //fn slice(&self, start: uint, end: uint) -> &'a [T];
/// Returns a subslice from `start` to the end of the slice.
///
///
/// Slicing from `self.len()` yields an empty slice.
#[unstable = "waiting on final error conventions"]
- fn slice_from(&self, start: uint) -> &'a [T];
+ // TODO
+ //fn slice_from(&self, start: uint) -> &'a [T];
/// Returns a subslice from the start of the slice to `end`.
///
///
/// Slicing to `0` yields an empty slice.
#[unstable = "waiting on final error conventions"]
- fn slice_to(&self, end: uint) -> &'a [T];
+ //fn slice_to(&self, end: uint) -> &'a [T];
/// Divides one slice into two at an index.
///
fn tail(&self) -> &'a [T];
/// Returns all but the first `n' elements of a slice.
- #[deprecated = "use slice_from"]
+ #[deprecated = "use slicing syntax"]
fn tailn(&self, n: uint) -> &'a [T];
/// Returns all but the last element of a slice.
/// Returns all but the last `n' elements of a slice.
#[deprecated = "use slice_to but note the arguments are different"]
+ #[deprecated = "use slicing syntax, but note the arguments are different"]
fn initn(&self, n: uint) -> &'a [T];
/// Returns the last element of a slice, or `None` if it is empty.
* ```ignore
* if self.len() == 0 { return None }
* let head = &self[0];
- * *self = self.slice_from(1);
+ * *self = self[1..];
* Some(head)
* ```
*
* ```ignore
* if self.len() == 0 { return None; }
* let tail = &self[self.len() - 1];
- * *self = self.slice_to(self.len() - 1);
+ * *self = self[..self.len() - 1];
* Some(tail)
* ```
*
#[unstable]
impl<'a,T> ImmutableSlice<'a, T> for &'a [T] {
- #[inline]
- fn slice(&self, start: uint, end: uint) -> &'a [T] {
- assert!(start <= end);
- assert!(end <= self.len());
- unsafe {
- transmute(RawSlice {
- data: self.as_ptr().offset(start as int),
- len: (end - start)
- })
- }
- }
-
- #[inline]
- fn slice_from(&self, start: uint) -> &'a [T] {
- self.slice(start, self.len())
- }
-
- #[inline]
- fn slice_to(&self, end: uint) -> &'a [T] {
- self.slice(0, end)
- }
-
#[inline]
fn split_at(&self, mid: uint) -> (&'a [T], &'a [T]) {
- (self.slice(0, mid), self.slice(mid, self.len()))
+ ((*self)[..mid], (*self)[mid..])
}
#[inline]
}
#[inline]
- fn tail(&self) -> &'a [T] { self.slice(1, self.len()) }
+ fn tail(&self) -> &'a [T] { (*self)[1..] }
#[inline]
- #[deprecated = "use slice_from"]
- fn tailn(&self, n: uint) -> &'a [T] { self.slice(n, self.len()) }
+ #[deprecated = "use slicing syntax"]
+ fn tailn(&self, n: uint) -> &'a [T] { (*self)[n..] }
#[inline]
fn init(&self) -> &'a [T] {
- self.slice(0, self.len() - 1)
+ (*self)[..self.len() - 1]
}
#[inline]
- #[deprecated = "use slice_to but note the arguments are different"]
+ #[deprecated = "use slicing syntax but note the arguments are different"]
fn initn(&self, n: uint) -> &'a [T] {
- self.slice(0, self.len() - n)
+ (*self)[..self.len() - n]
}
#[inline]
fn get_mut(self, index: uint) -> Option<&'a mut T>;
/// Work with `self` as a mut slice.
/// Primarily intended for getting a &mut [T] from a [T, ..N].
+ #[deprecated = "use slicing syntax"]
fn as_mut_slice(self) -> &'a mut [T];
/// Deprecated: use `slice_mut`.
- #[deprecated = "use slice_mut"]
- fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] {
- self.slice_mut(start, end)
- }
+ #[deprecated = "use slicing syntax"]
+ //fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] {
+ // self[mut start..end]
+ //}
/// Returns a mutable subslice spanning the interval [`start`, `end`).
///
///
/// Slicing with `start` equal to `end` yields an empty slice.
#[unstable = "waiting on final error conventions"]
- fn slice_mut(self, start: uint, end: uint) -> &'a mut [T];
+ //fn slice_mut(self, start: uint, end: uint) -> &'a mut [T];
- /// Deprecated: use `slice_from_mut`.
- #[deprecated = "use slice_from_mut"]
- fn mut_slice_from(self, start: uint) -> &'a mut [T] {
- self.slice_from_mut(start)
- }
+ /// Deprecated: use `slicing syntax`.
+ #[deprecated = "use slicing syntax"]
+ //fn mut_slice_from(self, start: uint) -> &'a mut [T] {
+ // self[mut start..]
+ //}
/// Returns a mutable subslice from `start` to the end of the slice.
///
///
/// Slicing from `self.len()` yields an empty slice.
#[unstable = "waiting on final error conventions"]
- fn slice_from_mut(self, start: uint) -> &'a mut [T];
+ //fn slice_from_mut(self, start: uint) -> &'a mut [T];
- /// Deprecated: use `slice_to_mut`.
- #[deprecated = "use slice_to_mut"]
- fn mut_slice_to(self, end: uint) -> &'a mut [T] {
- self.slice_to_mut(end)
- }
+ /// Deprecated: use `slicing syntax`.
+ #[deprecated = "use slicing syntax"]
+ //fn mut_slice_to(self, end: uint) -> &'a mut [T] {
+ // self[mut ..end]
+ //}
/// Returns a mutable subslice from the start of the slice to `end`.
///
///
/// Slicing to `0` yields an empty slice.
#[unstable = "waiting on final error conventions"]
- fn slice_to_mut(self, end: uint) -> &'a mut [T];
+ //fn slice_to_mut(self, end: uint) -> &'a mut [T];
/// Deprecated: use `iter_mut`.
#[deprecated = "use iter_mut"]
* ```ignore
* if self.len() == 0 { return None; }
* let head = &mut self[0];
- * *self = self.slice_from_mut(1);
+ * *self = self[mut 1..];
* Some(head)
* ```
*
* ```ignore
* if self.len() == 0 { return None; }
* let tail = &mut self[self.len() - 1];
- * *self = self.slice_to_mut(self.len() - 1);
+ * *self = self[mut ..self.len() - 1];
* Some(tail)
* ```
*
#[inline]
fn as_mut_slice(self) -> &'a mut [T] { self }
- fn slice_mut(self, start: uint, end: uint) -> &'a mut [T] {
- assert!(start <= end);
- assert!(end <= self.len());
- unsafe {
- transmute(RawSlice {
- data: self.as_mut_ptr().offset(start as int) as *const T,
- len: (end - start)
- })
- }
- }
-
- #[inline]
- fn slice_from_mut(self, start: uint) -> &'a mut [T] {
- let len = self.len();
- self.slice_mut(start, len)
- }
-
- #[inline]
- fn slice_to_mut(self, end: uint) -> &'a mut [T] {
- self.slice_mut(0, end)
- }
-
#[inline]
fn split_at_mut(self, mid: uint) -> (&'a mut [T], &'a mut [T]) {
unsafe {
- let len = self.len();
let self2: &'a mut [T] = mem::transmute_copy(&self);
- (self.slice_mut(0, mid), self2.slice_mut(mid, len))
+ (self[mut ..mid], self2[mut mid..])
}
}
#[inline]
fn starts_with(&self, needle: &[T]) -> bool {
let n = needle.len();
- self.len() >= n && needle == self.slice_to(n)
+ self.len() >= n && needle == (*self)[..n]
}
#[inline]
fn ends_with(&self, needle: &[T]) -> bool {
let (m, n) = (self.len(), needle.len());
- m >= n && needle == self.slice_from(m - n)
+ m >= n && needle == (*self)[m-n..]
}
}
match self.v.iter().position(|x| (self.pred)(x)) {
None => self.finish(),
Some(idx) => {
- let ret = Some(self.v.slice(0, idx));
- self.v = self.v.slice(idx + 1, self.v.len());
+ let ret = Some(self.v[..idx]);
+ self.v = self.v[idx + 1..];
ret
}
}
match self.v.iter().rposition(|x| (self.pred)(x)) {
None => self.finish(),
Some(idx) => {
- let ret = Some(self.v.slice(idx + 1, self.v.len()));
- self.v = self.v.slice(0, idx);
+ let ret = Some(self.v[idx + 1..]);
+ self.v = self.v[..idx];
ret
}
}
Some(idx) => {
let tmp = mem::replace(&mut self.v, &mut []);
let (head, tail) = tmp.split_at_mut(idx);
- self.v = tail.slice_from_mut(1);
+ self.v = tail[mut 1..];
Some(head)
}
}
let tmp = mem::replace(&mut self.v, &mut []);
let (head, tail) = tmp.split_at_mut(idx);
self.v = head;
- Some(tail.slice_from_mut(1))
+ Some(tail[mut 1..])
}
}
}
if self.size > self.v.len() {
None
} else {
- let ret = Some(self.v.slice(0, self.size));
- self.v = self.v.slice(1, self.v.len());
+ let ret = Some(self.v[..self.size]);
+ self.v = self.v[1..];
ret
}
}
let mut hi = lo + self.size;
if hi < lo || hi > self.v.len() { hi = self.v.len(); }
- Some(self.v.slice(lo, hi))
+ Some(self.v[lo..hi])
} else {
None
}
use num::{CheckedMul, Saturating};
use option::{Option, None, Some};
use raw::Repr;
-use slice::{ImmutableSlice, MutableSlice};
+use slice::ImmutableSlice;
use slice;
use uint;
fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> {
while self.position + needle.len() <= haystack.len() {
- if haystack.slice(self.position, self.position + needle.len()) == needle {
+ if haystack[self.position .. self.position + needle.len()] == needle {
let match_pos = self.position;
self.position += needle.len(); // add 1 for all matches
return Some((match_pos, match_pos + needle.len()));
//
// What's going on is we have some critical factorization (u, v) of the
// needle, and we want to determine whether u is a suffix of
- // v.slice_to(period). If it is, we use "Algorithm CP1". Otherwise we use
+ // v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
// "Algorithm CP2", which is optimized for when the period of the needle
// is large.
- if needle.slice_to(crit_pos) == needle.slice(period, period + crit_pos) {
+ if needle[..crit_pos] == needle[period.. period + crit_pos] {
TwoWaySearcher {
crit_pos: crit_pos,
period: period,
let mut buf = [0u16, ..2];
self.chars.next().map(|ch| {
- let n = ch.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
+ let n = ch.encode_utf16(buf[mut]).unwrap_or(0);
if n == 2 { self.extra = buf[1]; }
buf[0]
})
pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
match v.iter().position(|c| *c == 0) {
// don't include the 0
- Some(i) => v.slice_to(i),
+ Some(i) => v[..i],
None => v
}
}
#[inline]
fn starts_with<'a>(&self, needle: &'a str) -> bool {
let n = needle.len();
- self.len() >= n && needle.as_bytes() == self.as_bytes().slice_to(n)
+ self.len() >= n && needle.as_bytes() == self.as_bytes()[..n]
}
#[inline]
fn ends_with(&self, needle: &str) -> bool {
let (m, n) = (self.len(), needle.len());
- m >= n && needle.as_bytes() == self.as_bytes().slice_from(m - n)
+ m >= n && needle.as_bytes() == self.as_bytes()[m-n..]
}
#[inline]
fn check(input: char, expect: &[u8]) {
let mut buf = [0u8, ..4];
let n = input.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
- assert_eq!(buf.slice_to(n), expect);
+ assert_eq!(buf[..n], expect);
}
check('x', [0x78]);
fn check(input: char, expect: &[u16]) {
let mut buf = [0u16, ..2];
let n = input.encode_utf16(buf.as_mut_slice()).unwrap_or(0);
- assert_eq!(buf.slice_to(n), expect);
+ assert_eq!(buf[..n], expect);
}
check('x', [0x0078]);
use core::uint;
use core::cmp;
use core::num;
+use core::ops::Slice;
use test::Bencher;
.collect::<Vec<uint>>();
assert_eq!(n, xs.len());
- assert_eq!(xs.as_slice(), ys.as_slice());
+ assert_eq!(xs[], ys[]);
}
#[test]
#[test]
fn test_iterator_nth() {
- let v = &[0i, 1, 2, 3, 4];
+ let v: &[_] = &[0i, 1, 2, 3, 4];
for i in range(0u, v.len()) {
assert_eq!(v.iter().nth(i).unwrap(), &v[i]);
}
#[test]
fn test_iterator_last() {
- let v = &[0i, 1, 2, 3, 4];
+ let v: &[_] = &[0i, 1, 2, 3, 4];
assert_eq!(v.iter().last().unwrap(), &4);
- assert_eq!(v.slice(0, 1).iter().last().unwrap(), &0);
+ assert_eq!(v[0..1].iter().last().unwrap(), &0);
}
#[test]
fn test_iterator_len() {
- let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- assert_eq!(v.slice(0, 4).iter().count(), 4);
- assert_eq!(v.slice(0, 10).iter().count(), 10);
- assert_eq!(v.slice(0, 0).iter().count(), 0);
+ let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ assert_eq!(v[0..4].iter().count(), 4);
+ assert_eq!(v[0..10].iter().count(), 10);
+ assert_eq!(v[0..0].iter().count(), 0);
}
#[test]
fn test_iterator_sum() {
- let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- assert_eq!(v.slice(0, 4).iter().map(|&x| x).sum(), 6);
+ let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ assert_eq!(v[0..4].iter().map(|&x| x).sum(), 6);
assert_eq!(v.iter().map(|&x| x).sum(), 55);
- assert_eq!(v.slice(0, 0).iter().map(|&x| x).sum(), 0);
+ assert_eq!(v[0..0].iter().map(|&x| x).sum(), 0);
}
#[test]
fn test_iterator_product() {
- let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- assert_eq!(v.slice(0, 4).iter().map(|&x| x).product(), 0);
- assert_eq!(v.slice(1, 5).iter().map(|&x| x).product(), 24);
- assert_eq!(v.slice(0, 0).iter().map(|&x| x).product(), 1);
+ let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ assert_eq!(v[0..4].iter().map(|&x| x).product(), 0);
+ assert_eq!(v[1..5].iter().map(|&x| x).product(), 24);
+ assert_eq!(v[0..0].iter().map(|&x| x).product(), 1);
}
#[test]
fn test_iterator_max() {
- let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- assert_eq!(v.slice(0, 4).iter().map(|&x| x).max(), Some(3));
+ let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ assert_eq!(v[0..4].iter().map(|&x| x).max(), Some(3));
assert_eq!(v.iter().map(|&x| x).max(), Some(10));
- assert_eq!(v.slice(0, 0).iter().map(|&x| x).max(), None);
+ assert_eq!(v[0..0].iter().map(|&x| x).max(), None);
}
#[test]
fn test_iterator_min() {
- let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
- assert_eq!(v.slice(0, 4).iter().map(|&x| x).min(), Some(0));
+ let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
+ assert_eq!(v[0..4].iter().map(|&x| x).min(), Some(0));
assert_eq!(v.iter().map(|&x| x).min(), Some(0));
- assert_eq!(v.slice(0, 0).iter().map(|&x| x).min(), None);
+ assert_eq!(v[0..0].iter().map(|&x| x).min(), None);
}
#[test]
fn test_iterator_size_hint() {
let c = count(0i, 1);
- let v = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9];
+ let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9];
let v2 = &[10i, 11, 12];
let vi = v.iter();
assert!(v.iter().all(|&x| x < 10));
assert!(!v.iter().all(|&x| x % 2 == 0));
assert!(!v.iter().all(|&x| x > 100));
- assert!(v.slice(0, 0).iter().all(|_| fail!()));
+ assert!(v.slice_(&0, &0).iter().all(|_| fail!()));
}
#[test]
assert!(v.iter().any(|&x| x < 10));
assert!(v.iter().any(|&x| x % 2 == 0));
assert!(!v.iter().any(|&x| x > 100));
- assert!(!v.slice(0, 0).iter().any(|_| fail!()));
+ assert!(!v.slice_(&0, &0).iter().any(|_| fail!()));
}
#[test]
fn test_double_ended_flat_map() {
let u = [0u,1];
let v = [5u,6,7,8];
- let mut it = u.iter().flat_map(|x| v.slice(*x, v.len()).iter());
+ let mut it = u.iter().flat_map(|x| v[*x..v.len()].iter());
assert_eq!(it.next_back().unwrap(), &8);
assert_eq!(it.next().unwrap(), &5);
assert_eq!(it.next_back().unwrap(), &7);
// Also as with read(), we use MSG_DONTWAIT to guard ourselves
// against unforeseen circumstances.
let _guard = lock();
- let ptr = buf.slice_from(written).as_ptr();
+ let ptr = buf[written..].as_ptr();
let len = buf.len() - written;
match retry(|| write(deadline.is_some(), ptr, len)) {
-1 if util::wouldblock() => {}
let mut power: BigUint = One::one();
loop {
let start = cmp::max(end, unit_len) - unit_len;
- match uint::parse_bytes(buf.slice(start, end), radix) {
+ match uint::parse_bytes(buf[start..end], radix) {
Some(d) => {
let d: Option<BigUint> = FromPrimitive::from_uint(d);
match d {
sign = Minus;
start = 1;
}
- return BigUint::parse_bytes(buf.slice(start, buf.len()), radix)
+ return BigUint::parse_bytes(buf[start..], radix)
.map(|bu| BigInt::from_biguint(sign, bu));
}
/// let choices = [1i, 2, 4, 8, 16, 32];
/// let mut rng = task_rng();
/// println!("{}", rng.choose(choices));
- /// assert_eq!(rng.choose(choices.slice_to(0)), None);
+ /// assert_eq!(rng.choose(choices[..0]), None);
/// ```
fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
if values.is_empty() {
// there (left), and what will be appended on the end (right)
let cap = self.buf.len() - self.pos;
let (left, right) = if cap <= buf.len() {
- (buf.slice_to(cap), buf.slice_from(cap))
+ (buf[..cap], buf[cap..])
} else {
let result: (_, &[_]) = (buf, &[]);
result
// Do the necessary writes
if left.len() > 0 {
- slice::bytes::copy_memory(self.buf.slice_from_mut(self.pos), left);
+ slice::bytes::copy_memory(self.buf[mut self.pos..], left);
}
if right.len() > 0 {
self.buf.push_all(right);
}
pub fn as_str_slice<'a>(&'a self) -> &'a str {
- str::from_utf8(self.data.slice(self.start, self.end)).unwrap()
+ str::from_utf8(self.data[self.start..self.end]).unwrap()
}
pub fn as_str(&self) -> String {
}
pub fn with_doc_data<'a, T>(d: Doc<'a>, f: |x: &'a [u8]| -> T) -> T {
- f(d.data.slice(d.start, d.end))
+ f(d.data[d.start..d.end])
}
// This is a bit hacky since we have to skip over the initial
// 'Save' instruction.
let mut pre = String::with_capacity(5);
- for inst in c.insts.slice_from(1).iter() {
+ for inst in c.insts[1..].iter() {
match *inst {
OneChar(c, FLAG_EMPTY) => pre.push(c),
_ => break
self.chari = closer;
let greed = try!(self.get_next_greedy());
let inner = String::from_chars(
- self.chars.as_slice().slice(start + 1, closer));
+ self.chars[start+1..closer]);
// Parse the min and max values from the regex.
let (mut min, mut max): (uint, Option<uint>);
}
fn slice(&self, start: uint, end: uint) -> String {
- String::from_chars(self.chars.as_slice().slice(start, end))
+ String::from_chars(self.chars[start..end])
}
}
// actual capture groups to match test set.
let (sexpect, mut sgot) = (expected.as_slice(), got.as_slice());
if sgot.len() > sexpect.len() {
- sgot = sgot.slice(0, sexpect.len())
+ sgot = sgot[0..sexpect.len()]
}
if sexpect != sgot {
fail!("For RE '{}' against '{}', expected '{}' but got '{}'",
// out early.
if self.prog.prefix.len() > 0 && clist.size == 0 {
let needle = self.prog.prefix.as_slice().as_bytes();
- let haystack = self.input.as_bytes().slice_from(self.ic);
+ let haystack = self.input.as_bytes()[self.ic..];
match find_prefix(needle, haystack) {
None => break,
Some(i) => {
} else {
quote_expr!(self.cx,
if clist.size == 0 {
- let haystack = self.input.as_bytes().slice_from(self.ic);
+ let haystack = self.input.as_bytes()[self.ic..];
match find_prefix(prefix_bytes, haystack) {
None => break,
Some(i) => {
if version == 1 {
// The only version existing so far
let data_size = extract_compressed_bytecode_size_v1(bc_encoded);
- let compressed_data = bc_encoded.slice(
- link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET,
- link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint);
+ let compressed_data = bc_encoded[
+ link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET..
+ link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint];
match flate::inflate_bytes(compressed_data) {
Some(inflated) => inflated,
fn is_versioned_bytecode_format(bc: &[u8]) -> bool {
let magic_id_byte_count = link::RLIB_BYTECODE_OBJECT_MAGIC.len();
return bc.len() > magic_id_byte_count &&
- bc.slice(0, magic_id_byte_count) == link::RLIB_BYTECODE_OBJECT_MAGIC;
+ bc[..magic_id_byte_count] == link::RLIB_BYTECODE_OBJECT_MAGIC;
}
fn extract_bytecode_format_version(bc: &[u8]) -> u32 {
}
fn read_from_le_bytes<T: Int>(bytes: &[u8], position_in_bytes: uint) -> T {
- let byte_data = bytes.slice(position_in_bytes,
- position_in_bytes + mem::size_of::<T>());
+ let byte_data = bytes[position_in_bytes..
+ position_in_bytes + mem::size_of::<T>()];
let data = unsafe {
*(byte_data.as_ptr() as *const T)
};
let mut ret = None;
reader::tagged_docs(tagged_doc.doc, belt, |elt| {
let pos = u64_from_be_bytes(elt.data, elt.start, 4) as uint;
- if eq_fn(elt.data.slice(elt.start + 4, elt.end)) {
+ if eq_fn(elt.data[elt.start + 4 .. elt.end]) {
ret = Some(reader::doc_at(d.data, pos).unwrap().doc);
false
} else {
items: rbml::Doc<'a>) -> Option<rbml::Doc<'a>> {
fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
return u64_from_be_bytes(
- bytes.slice(0u, 4u), 0u, 4u) as ast::NodeId
+ bytes[0u..4u], 0u, 4u) as ast::NodeId
== item_id;
}
lookup_hash(items,
}
let end_pos = st.pos;
st.pos += 1;
- return op(st.data.slice(start_pos, end_pos));
+ return op(st.data[start_pos..end_pos]);
}
pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
fail!();
}
- let crate_part = buf.slice(0u, colon_idx);
- let def_part = buf.slice(colon_idx + 1u, len);
+ let crate_part = buf[0u..colon_idx];
+ let def_part = buf[colon_idx + 1u..len];
let crate_num = match uint::parse_bytes(crate_part, 10u) {
Some(cn) => cn as ast::CrateNum,
None
}
};
- head.map(|head| head.append(r.slice_to(col)).append(r.slice_from(col + 1)))
+ head.map(|head| head.append(r[..col]).append(r[col + 1..]))
}
fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) {
for (i, rib) in ribs.iter().enumerate().rev() {
match rib.bindings.find_copy(&name) {
Some(def_like) => {
- return self.upvarify(ribs.slice_from(i + 1), def_like, span);
+ return self.upvarify(ribs[i + 1..], def_like, span);
}
None => {
// Continue.
if len <= 2 {
return;
}
- let sub_paths = sub_paths.slice(0, len-2);
+ let sub_paths = sub_paths[..len-2];
for &(ref span, ref qualname) in sub_paths.iter() {
self.fmt.sub_mod_ref_str(path.span,
*span,
// Collect all of the matches that can match against anything.
enter_match(bcx, dm, m, col, val, |pats| {
if pat_is_binding_or_wild(dm, &*pats[col]) {
- Some(Vec::from_slice(pats.slice_to(col)).append(pats.slice_from(col + 1)))
+ Some(Vec::from_slice(pats[..col]).append(pats[col + 1..]))
} else {
None
}
bcx = compile_guard(bcx,
&**guard_expr,
m[0].data,
- m.slice(1, m.len()),
+ m[1..m.len()],
vals,
chk,
has_genuine_default);
let tcx = bcx.tcx();
let dm = &tcx.def_map;
- let vals_left = Vec::from_slice(vals.slice(0u, col)).append(vals.slice(col + 1u, vals.len()));
+ let vals_left = Vec::from_slice(vals[0u..col]).append(vals[col + 1u..vals.len()]);
let ccx = bcx.fcx.ccx;
// Find a real id (we're adding placeholder wildcard patterns, but
for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) {
*small_vec_e = C_i32(self.ccx, ix as i32);
}
- self.inbounds_gep(base, small_vec.slice(0, ixs.len()))
+ self.inbounds_gep(base, small_vec[..ixs.len()])
} else {
let v = ixs.iter().map(|i| C_i32(self.ccx, *i as i32)).collect::<Vec<ValueRef>>();
self.count_insn("gepi");
let variable_access = IndirectVariable {
alloca: env_pointer,
- address_operations: address_operations.slice_to(address_op_count)
+ address_operations: address_operations[..address_op_count]
};
declare_local(bcx,
}
}
- for param in ty_param_defs.slice_from(supplied_ty_param_count).iter() {
+ for param in ty_param_defs[supplied_ty_param_count..].iter() {
match param.default {
Some(default) => {
// This is a default type parameter.
};
// Call the generic checker.
- let args: Vec<_> = args.slice_from(1).iter().map(|x| x).collect();
+ let args: Vec<_> = args[1..].iter().map(|x| x).collect();
let ret_ty = check_method_argument_types(fcx,
method_name.span,
fn_ty,
0
};
- for t in tps.slice_to(tps.len() - num_defaults).iter() {
+ for t in tps[..tps.len() - num_defaults].iter() {
strs.push(ty_to_string(cx, *t))
}
let buffer_remaining = size - self.buffer_idx;
if input.len() >= buffer_remaining {
copy_memory(
- self.buffer.slice_mut(self.buffer_idx, size),
- input.slice_to(buffer_remaining));
+ self.buffer[mut self.buffer_idx..size],
+ input[..buffer_remaining]);
self.buffer_idx = 0;
func(self.buffer);
i += buffer_remaining;
} else {
copy_memory(
- self.buffer.slice_mut(self.buffer_idx, self.buffer_idx + input.len()),
+ self.buffer[mut self.buffer_idx..self.buffer_idx + input.len()],
input);
self.buffer_idx += input.len();
return;
// While we have at least a full buffer size chunk's worth of data, process that data
// without copying it into the buffer
while input.len() - i >= size {
- func(input.slice(i, i + size));
+ func(input[i..i + size]);
i += size;
}
// be empty.
let input_remaining = input.len() - i;
copy_memory(
- self.buffer.slice_mut(0, input_remaining),
- input.slice_from(i));
+ self.buffer[mut ..input_remaining],
+ input[i..]);
self.buffer_idx += input_remaining;
}
fn zero_until(&mut self, idx: uint) {
assert!(idx >= self.buffer_idx);
- self.buffer.slice_mut(self.buffer_idx, idx).set_memory(0);
+ self.buffer[mut self.buffer_idx..idx].set_memory(0);
self.buffer_idx = idx;
}
fn next<'s>(&'s mut self, len: uint) -> &'s mut [u8] {
self.buffer_idx += len;
- return self.buffer.slice_mut(self.buffer_idx - len, self.buffer_idx);
+ return self.buffer[mut self.buffer_idx - len..self.buffer_idx];
}
fn full_buffer<'s>(&'s mut self) -> &'s [u8] {
assert!(self.buffer_idx == 64);
self.buffer_idx = 0;
- return self.buffer.slice_to(64);
+ return self.buffer[..64];
}
fn position(&self) -> uint { self.buffer_idx }
)
)
- read_u32v_be(w.slice_mut(0, 16), data);
+ read_u32v_be(w[mut 0..16], data);
// Putting the message schedule inside the same loop as the round calculations allows for
// the compiler to generate better code.
fn result(&mut self, out: &mut [u8]) {
self.engine.finish();
- write_u32_be(out.slice_mut(0, 4), self.engine.state.h0);
- write_u32_be(out.slice_mut(4, 8), self.engine.state.h1);
- write_u32_be(out.slice_mut(8, 12), self.engine.state.h2);
- write_u32_be(out.slice_mut(12, 16), self.engine.state.h3);
- write_u32_be(out.slice_mut(16, 20), self.engine.state.h4);
- write_u32_be(out.slice_mut(20, 24), self.engine.state.h5);
- write_u32_be(out.slice_mut(24, 28), self.engine.state.h6);
- write_u32_be(out.slice_mut(28, 32), self.engine.state.h7);
+ write_u32_be(out[mut 0..4], self.engine.state.h0);
+ write_u32_be(out[mut 4..8], self.engine.state.h1);
+ write_u32_be(out[mut 8..12], self.engine.state.h2);
+ write_u32_be(out[mut 12..16], self.engine.state.h3);
+ write_u32_be(out[mut 16..20], self.engine.state.h4);
+ write_u32_be(out[mut 20..24], self.engine.state.h5);
+ write_u32_be(out[mut 24..28], self.engine.state.h6);
+ write_u32_be(out[mut 28..32], self.engine.state.h7);
}
fn reset(&mut self) {
let all_inputs = &self.pe_fn_decl().inputs;
let inputs = match self.pe_explicit_self().node {
ast::SelfStatic => all_inputs.as_slice(),
- _ => all_inputs.slice_from(1)
+ _ => all_inputs[1..]
};
let decl = FnDecl {
inputs: Arguments {
fn clean(&self, cx: &DocContext) -> Item {
let inputs = match self.explicit_self.node {
ast::SelfStatic => self.decl.inputs.as_slice(),
- _ => self.decl.inputs.slice_from(1)
+ _ => self.decl.inputs[1..]
};
let decl = FnDecl {
inputs: Arguments {
self.fty.sig.clone()),
s => {
let sig = ty::FnSig {
- inputs: self.fty.sig.inputs.slice_from(1).to_vec(),
+ inputs: self.fty.sig.inputs[1..].to_vec(),
..self.fty.sig.clone()
};
let s = match s {
match rel_root {
Some(root) => {
let mut root = String::from_str(root.as_slice());
- for seg in path.segments.slice_to(amt).iter() {
+ for seg in path.segments[..amt].iter() {
if "super" == seg.name.as_slice() ||
"self" == seg.name.as_slice() {
try!(write!(w, "{}::", seg.name));
}
}
None => {
- for seg in path.segments.slice_to(amt).iter() {
+ for seg in path.segments[..amt].iter() {
try!(write!(w, "{}::", seg.name));
}
}
// This is a documented path, link to it!
Some((ref fqp, shortty)) if abs_root.is_some() => {
let mut url = String::from_str(abs_root.unwrap().as_slice());
- let to_link = fqp.slice_to(fqp.len() - 1);
+ let to_link = fqp[..fqp.len() - 1];
for component in to_link.iter() {
url.push_str(component.as_slice());
url.push_str("/");
search_index.push(IndexItem {
ty: shortty(item),
name: item.name.clone().unwrap(),
- path: fqp.slice_to(fqp.len() - 1).connect("::"),
+ path: fqp[..fqp.len() - 1].connect("::"),
desc: shorter(item.doc_value()).to_string(),
parent: Some(did),
});
};
let mut mydst = dst.clone();
- for part in remote_path.slice_to(remote_path.len() - 1).iter() {
+ for part in remote_path[..remote_path.len() - 1].iter() {
mydst.push(part.as_slice());
try!(mkdir(&mydst));
}
clean::StructFieldItem(..) |
clean::VariantItem(..) => {
((Some(*self.parent_stack.last().unwrap()),
- Some(self.stack.slice_to(self.stack.len() - 1))),
+ Some(self.stack[..self.stack.len() - 1])),
false)
}
clean::MethodItem(..) => {
let did = *last;
let path = match self.paths.find(&did) {
Some(&(_, item_type::Trait)) =>
- Some(self.stack.slice_to(self.stack.len() - 1)),
+ Some(self.stack[..self.stack.len() - 1]),
// The current stack not necessarily has correlation for
// where the type was defined. On the other hand,
// `paths` always has the right information if present.
Some(&(ref fqp, item_type::Struct)) |
Some(&(ref fqp, item_type::Enum)) =>
- Some(fqp.slice_to(fqp.len() - 1)),
+ Some(fqp[..fqp.len() - 1]),
Some(..) => Some(self.stack.as_slice()),
None => None
};
let mut url = "../".repeat(cx.current.len());
match cache_key.get().unwrap().paths.find(&it.def_id) {
Some(&(ref names, _)) => {
- for name in names.slice_to(names.len() - 1).iter() {
+ for name in names[..names.len() - 1].iter() {
url.push_str(name.as_slice());
url.push_str("/");
}
// MAX_CALLBACKS, so we're sure to clamp it as necessary.
let callbacks = unsafe {
let amt = CALLBACK_CNT.load(atomic::SeqCst);
- CALLBACKS.slice_to(cmp::min(amt, MAX_CALLBACKS))
+ CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
};
for cb in callbacks.iter() {
match cb.load(atomic::SeqCst) {
}
impl<'a> FormatWriter for BufWriter<'a> {
fn write(&mut self, bytes: &[u8]) -> fmt::Result {
- let left = self.buf.slice_from_mut(self.pos);
- let to_write = bytes.slice_to(cmp::min(bytes.len(), left.len()));
+ let left = self.buf[mut self.pos..];
+ let to_write = bytes[..cmp::min(bytes.len(), left.len())];
slice::bytes::copy_memory(left, to_write);
self.pos += to_write.len();
Ok(())
let mut msg = [0u8, ..512];
let mut w = BufWriter { buf: msg, pos: 0 };
let _ = write!(&mut w, "{}", args);
- let msg = str::from_utf8(w.buf.slice_to(w.pos)).unwrap_or("aborted");
+ let msg = str::from_utf8(w.buf[mut ..w.pos]).unwrap_or("aborted");
let msg = if msg.is_empty() {"aborted"} else {msg};
// Give some context to the message
};
if start < i {
- try!(wr.write(bytes.slice(start, i)));
+ try!(wr.write(bytes[start..i]));
}
try!(wr.write_str(escaped));
}
if start != bytes.len() {
- try!(wr.write(bytes.slice_from(start)));
+ try!(wr.write(bytes[start..]));
}
wr.write_str("\"")
}
if n > 0 {
- wr.write(buf.slice_to(n))
+ wr.write(buf[..n])
} else {
Ok(())
}
InternalIndex(i) => { Index(i) }
InternalKey(start, size) => {
Key(str::from_utf8(
- self.str_buffer.slice(start as uint, start as uint + size as uint)).unwrap())
+ self.str_buffer[start as uint .. start as uint + size as uint]).unwrap())
}
}
}
Some(&InternalIndex(i)) => Some(Index(i)),
Some(&InternalKey(start, size)) => {
Some(Key(str::from_utf8(
- self.str_buffer.slice(start as uint, (start+size) as uint)
+ self.str_buffer[start as uint .. (start+size) as uint]
).unwrap()))
}
}
impl<R: Reader> Buffer for BufferedReader<R> {
fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
if self.pos == self.cap {
- self.cap = try!(self.inner.read(self.buf.as_mut_slice()));
+ self.cap = try!(self.inner.read(self.buf[mut]));
self.pos = 0;
}
- Ok(self.buf.slice(self.pos, self.cap))
+ Ok(self.buf[self.pos..self.cap])
}
fn consume(&mut self, amt: uint) {
let nread = {
let available = try!(self.fill_buf());
let nread = cmp::min(available.len(), buf.len());
- slice::bytes::copy_memory(buf, available.slice_to(nread));
+ slice::bytes::copy_memory(buf, available[..nread]);
nread
};
self.pos += nread;
fn flush_buf(&mut self) -> IoResult<()> {
if self.pos != 0 {
- let ret = self.inner.as_mut().unwrap().write(self.buf.slice_to(self.pos));
+ let ret = self.inner.as_mut().unwrap().write(self.buf[..self.pos]);
self.pos = 0;
ret
} else {
if buf.len() > self.buf.len() {
self.inner.as_mut().unwrap().write(buf)
} else {
- let dst = self.buf.slice_from_mut(self.pos);
+ let dst = self.buf[mut self.pos..];
slice::bytes::copy_memory(dst, buf);
self.pos += buf.len();
Ok(())
fn write(&mut self, buf: &[u8]) -> IoResult<()> {
match buf.iter().rposition(|&b| b == b'\n') {
Some(i) => {
- try!(self.inner.write(buf.slice_to(i + 1)));
+ try!(self.inner.write(buf[..i + 1]));
try!(self.inner.flush());
- try!(self.inner.write(buf.slice_from(i + 1)));
+ try!(self.inner.write(buf[i + 1..]));
Ok(())
}
None => self.inner.write(buf),
use io;
use option::{None, Option, Some};
use result::{Ok, Err};
-use slice::{bytes, MutableSlice, ImmutableSlice, CloneableVector};
-use str::StrSlice;
+use slice::{bytes, CloneableVector};
use super::{Reader, Writer, IoResult};
use vec::Vec;
loop {
match self.buf {
Some(ref prev) => {
- let dst = buf.slice_from_mut(num_read);
- let src = prev.slice_from(self.pos);
+ let dst = buf[mut num_read..];
+ let src = prev[self.pos..];
let count = cmp::min(dst.len(), src.len());
- bytes::copy_memory(dst, src.slice_to(count));
+ bytes::copy_memory(dst, src[..count]);
num_read += count;
self.pos += count;
},
Err(ref e) if e.kind == io::EndOfFile => { break }
Err(e) => return update_err(Err(e), from, to)
};
- try!(writer.write(buf.slice_to(amt)));
+ try!(writer.write(buf[..amt]));
}
chmod(to, try!(update_err(from.stat(), from, to)).perm)
let mut read_buf = [0, .. 1028];
let read_str = match check!(read_stream.read(read_buf)) {
-1|0 => fail!("shouldn't happen"),
- n => str::from_utf8(read_buf.slice_to(n)).unwrap().to_string()
+ n => str::from_utf8(read_buf[..n]).unwrap().to_string()
};
assert_eq!(read_str.as_slice(), message);
}
{
let mut read_stream = File::open_mode(filename, Open, Read);
{
- let read_buf = read_mem.slice_mut(0, 4);
+ let read_buf = read_mem[mut 0..4];
check!(read_stream.read(read_buf));
}
{
- let read_buf = read_mem.slice_mut(4, 8);
+ let read_buf = read_mem[mut 4..8];
check!(read_stream.read(read_buf));
}
}
use io;
use io::{Reader, Writer, Seek, Buffer, IoError, SeekStyle, IoResult};
use slice;
-use slice::{Slice, ImmutableSlice, MutableSlice};
+use slice::Slice;
use vec::Vec;
static BUF_CAPACITY: uint = 128;
let write_len = min(buf.len(), self.buf.len() - self.pos);
{
- let input = self.buf.slice(self.pos, self.pos + write_len);
- let output = buf.slice_mut(0, write_len);
+ let input = self.buf[self.pos.. self.pos + write_len];
+ let output = buf[mut ..write_len];
assert_eq!(input.len(), output.len());
slice::bytes::copy_memory(output, input);
}
#[inline]
fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
if self.pos < self.buf.len() {
- Ok(self.buf.slice_from(self.pos))
+ Ok(self.buf[self.pos..])
} else {
Err(io::standard_error(io::EndOfFile))
}
})
}
- slice::bytes::copy_memory(self.buf.slice_from_mut(self.pos), buf);
+ slice::bytes::copy_memory(self.buf[mut self.pos..], buf);
self.pos += buf.len();
Ok(())
}
let write_len = min(buf.len(), self.buf.len() - self.pos);
{
- let input = self.buf.slice(self.pos, self.pos + write_len);
- let output = buf.slice_mut(0, write_len);
+ let input = self.buf[self.pos.. self.pos + write_len];
+ let output = buf[mut ..write_len];
assert_eq!(input.len(), output.len());
slice::bytes::copy_memory(output, input);
}
#[inline]
fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
if self.pos < self.buf.len() {
- Ok(self.buf.slice_from(self.pos))
+ Ok(self.buf[self.pos..])
} else {
Err(io::standard_error(io::EndOfFile))
}
assert_eq!(buf.as_slice(), b);
assert_eq!(reader.read(buf), Ok(3));
let b: &[_] = &[5, 6, 7];
- assert_eq!(buf.slice(0, 3), b);
+ assert_eq!(buf[0..3], b);
assert!(reader.read(buf).is_err());
let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
assert_eq!(buf.as_slice(), b);
assert_eq!(reader.read(buf), Ok(3));
let b: &[_] = &[5, 6, 7];
- assert_eq!(buf.slice(0, 3), b);
+ assert_eq!(buf[0..3], b);
assert!(reader.read(buf).is_err());
let mut reader = BufReader::new(in_buf.as_slice());
assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
assert!(r.read_at_least(buf.len(), buf).is_ok());
let b: &[_] = &[1, 2, 3];
assert_eq!(buf.as_slice(), b);
- assert!(r.read_at_least(0, buf.slice_to_mut(0)).is_ok());
+ assert!(r.read_at_least(0, buf[mut ..0]).is_ok());
assert_eq!(buf.as_slice(), b);
assert!(r.read_at_least(buf.len(), buf).is_ok());
let b: &[_] = &[4, 5, 6];
use boxed::Box;
use result::{Ok, Err, Result};
use rt::rtio;
-use slice::{Slice, MutableSlice, ImmutableSlice};
+use slice::{Slice, ImmutableSlice};
use str::{Str, StrSlice};
use str;
use string::String;
while read < min {
let mut zeroes = 0;
loop {
- match self.read(buf.slice_from_mut(read)) {
+ match self.read(buf[mut read..]) {
Ok(0) => {
zeroes += 1;
if zeroes >= NO_PROGRESS_LIMIT {
#[inline]
fn write_char(&mut self, c: char) -> IoResult<()> {
let mut buf = [0u8, ..4];
- let n = c.encode_utf8(buf.as_mut_slice()).unwrap_or(0);
- self.write(buf.slice_to(n))
+ let n = c.encode_utf8(buf[mut]).unwrap_or(0);
+ self.write(buf[..n])
}
/// Write the result of passing n through `int::to_str_bytes`.
};
match available.iter().position(|&b| b == byte) {
Some(i) => {
- res.push_all(available.slice_to(i + 1));
+ res.push_all(available[..i + 1]);
used = i + 1;
break
}
{
let mut start = 1;
while start < width {
- match try!(self.read(buf.slice_mut(start, width))) {
+ match try!(self.read(buf[mut start..width])) {
n if n == width - start => break,
n if n < width - start => { start += n; }
_ => return Err(standard_error(InvalidInput)),
}
}
}
- match str::from_utf8(buf.slice_to(width)) {
+ match str::from_utf8(buf[..width]) {
Some(s) => Ok(s.char_at(0)),
None => Err(standard_error(InvalidInput))
}
use iter::Iterator;
use option::{Option, None, Some};
use str::StrSlice;
-use slice::{MutableCloneableSlice, ImmutableSlice, MutableSlice};
+use slice::{MutableCloneableSlice, MutableSlice};
pub type Port = u16;
assert!(head.len() + tail.len() <= 8);
let mut gs = [0u16, ..8];
gs.clone_from_slice(head);
- gs.slice_mut(8 - tail.len(), 8).clone_from_slice(tail);
+ gs[mut 8 - tail.len() .. 8].clone_from_slice(tail);
Ipv6Addr(gs[0], gs[1], gs[2], gs[3], gs[4], gs[5], gs[6], gs[7])
}
let mut tail = [0u16, ..8];
let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
- Some(ipv6_addr_from_head_tail(head.slice(0, head_size), tail.slice(0, tail_size)))
+ Some(ipv6_addr_from_head_tail(head[..head_size], tail[..tail_size]))
}
fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
/// match socket.recv_from(buf) {
/// Ok((amt, src)) => {
/// // Send a reply to the socket we received data from
-/// let buf = buf.slice_to_mut(amt);
+/// let buf = buf[mut ..amt];
/// buf.reverse();
/// socket.send_to(buf, src);
/// }
}
let len = cmp::min(self.limit, buf.len());
- let res = self.inner.read(buf.slice_to_mut(len));
+ let res = self.inner.read(buf[mut ..len]);
match res {
Ok(len) => self.limit -= len,
_ => {}
impl<R: Buffer> Buffer for LimitReader<R> {
fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> {
let amt = try!(self.inner.fill_buf());
- let buf = amt.slice_to(cmp::min(amt.len(), self.limit));
+ let buf = amt[..cmp::min(amt.len(), self.limit)];
if buf.len() == 0 {
Err(io::standard_error(io::EndOfFile))
} else {
impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
self.reader.read(buf).and_then(|len| {
- self.writer.write(buf.slice_to(len)).map(|()| len)
+ self.writer.write(buf[mut ..len]).map(|()| len)
})
}
}
Err(ref e) if e.kind == io::EndOfFile => return Ok(()),
Err(e) => return Err(e),
};
- try!(w.write(buf.slice_to(len)));
+ try!(w.write(buf[..len]));
}
}
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::i16::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::i32::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::i64::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::i8::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::int::{BITS, BYTES, MIN, MAX};
(write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap();
wr.tell().unwrap() as uint
};
- f(buf.slice(0, amt))
+ f(buf[..amt])
}
#[deprecated = "use fmt::radix"]
// parse remaining bytes as decimal integer,
// skipping the exponent char
let exp: Option<int> = from_str_bytes_common(
- buf.slice(i+1, len), 10, true, false, false, ExpNone, false,
+ buf[i+1..len], 10, true, false, false, ExpNone, false,
ignore_underscores);
match exp {
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::u16::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::u32::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::u64::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::u8::{BITS, BYTES, MIN, MAX};
use num::{ToStrRadix, FromStrRadix};
use num::strconv;
use option::Option;
-use slice::ImmutableSlice;
use string::String;
pub use core::uint::{BITS, BYTES, MIN, MAX};
(write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap();
wr.tell().unwrap() as uint
};
- f(buf.slice(0, amt))
+ f(buf[..amt])
}
#[deprecated = "use fmt::radix"]
match name.rposition_elem(&dot) {
None | Some(0) => name,
Some(1) if name == b".." => name,
- Some(pos) => name.slice_to(pos)
+ Some(pos) => name[..pos]
}
})
}
match name.rposition_elem(&dot) {
None | Some(0) => None,
Some(1) if name == b".." => None,
- Some(pos) => Some(name.slice_from(pos+1))
+ Some(pos) => Some(name[pos+1..])
}
}
}
let extlen = extension.container_as_bytes().len();
match (name.rposition_elem(&dot), extlen) {
(None, 0) | (Some(0), 0) => None,
- (Some(idx), 0) => Some(name.slice_to(idx).to_vec()),
+ (Some(idx), 0) => Some(name[..idx].to_vec()),
(idx, extlen) => {
let idx = match idx {
None | Some(0) => name.len(),
let mut v;
v = Vec::with_capacity(idx + extlen + 1);
- v.push_all(name.slice_to(idx));
+ v.push_all(name[..idx]);
v.push(dot);
v.push_all(extension.container_as_bytes());
Some(v)
None => {
self.repr = Path::normalize(filename);
}
- Some(idx) if self.repr.slice_from(idx+1) == b".." => {
+ Some(idx) if self.repr[idx+1..] == b".." => {
let mut v = Vec::with_capacity(self.repr.len() + 1 + filename.len());
v.push_all(self.repr.as_slice());
v.push(SEP_BYTE);
}
Some(idx) => {
let mut v = Vec::with_capacity(idx + 1 + filename.len());
- v.push_all(self.repr.slice_to(idx+1));
+ v.push_all(self.repr[..idx+1]);
v.push_all(filename);
// FIXME: this is slow
self.repr = Path::normalize(v.as_slice());
match self.sepidx {
None if b".." == self.repr.as_slice() => self.repr.as_slice(),
None => dot_static,
- Some(0) => self.repr.slice_to(1),
- Some(idx) if self.repr.slice_from(idx+1) == b".." => self.repr.as_slice(),
- Some(idx) => self.repr.slice_to(idx)
+ Some(0) => self.repr[..1],
+ Some(idx) if self.repr[idx+1..] == b".." => self.repr.as_slice(),
+ Some(idx) => self.repr[..idx]
}
}
None if b"." == self.repr.as_slice() ||
b".." == self.repr.as_slice() => None,
None => Some(self.repr.as_slice()),
- Some(idx) if self.repr.slice_from(idx+1) == b".." => None,
- Some(0) if self.repr.slice_from(1).is_empty() => None,
- Some(idx) => Some(self.repr.slice_from(idx+1))
+ Some(idx) if self.repr[idx+1..] == b".." => None,
+ Some(0) if self.repr[1..].is_empty() => None,
+ Some(idx) => Some(self.repr[idx+1..])
}
}
// borrowck is being very picky
let val = {
let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
- let v_ = if is_abs { v.as_slice().slice_from(1) } else { v.as_slice() };
+ let v_ = if is_abs { v.as_slice()[1..] } else { v.as_slice() };
let comps = normalize_helper(v_, is_abs);
match comps {
None => None,
/// A path of "/" yields no components. A path of "." yields one component.
pub fn components<'a>(&'a self) -> Components<'a> {
let v = if self.repr[0] == SEP_BYTE {
- self.repr.slice_from(1)
+ self.repr[1..]
} else { self.repr.as_slice() };
let mut ret = v.split(is_sep_byte);
if v.is_empty() {
NodesMatchingSuffix {
map: self,
item_name: parts.last().unwrap(),
- in_which: parts.slice_to(parts.len() - 1),
+ in_which: parts[..parts.len() - 1],
idx: 0,
}
}
let mut elided = false;
let mut display_lines = lines.lines.as_slice();
if display_lines.len() > MAX_LINES {
- display_lines = display_lines.slice(0u, MAX_LINES);
+ display_lines = display_lines[0u..MAX_LINES];
elided = true;
}
// Print the offending lines
// Find the offset of the NUL we want to go to
- let nulpos = string_table.slice(offset as uint, string_table_bytes as uint)
+ let nulpos = string_table[offset as uint .. string_table_bytes as uint]
.iter().position(|&b| b == 0);
match nulpos {
Some(len) => {
string_map.insert(name.to_string(),
- string_table.slice(offset as uint,
- offset as uint + len).to_vec())
+ string_table[offset as uint ..
+ offset as uint + len].to_vec())
},
None => {
return Err("invalid file: missing NUL in \
fn next_permutation(perm: &mut [i32], count: &mut [i32]) {
for i in range(1, perm.len()) {
- rotate(perm.slice_to_mut(i + 1));
+ rotate(perm[mut ..i + 1]);
let count_i = &mut count[i];
if *count_i >= i as i32 {
*count_i = 0;
let d = idx / self.fact[i] as i32;
self.cnt[i] = d;
idx %= self.fact[i] as i32;
- for (place, val) in pp.iter_mut().zip(self.perm.p.slice_to(i + 1).iter()) {
+ for (place, val) in pp.iter_mut().zip(self.perm.p[..i+1].iter()) {
*place = (*val) as u8
}
fn reverse(tperm: &mut [i32], mut k: uint) {
- tperm.slice_to_mut(k).reverse()
+ tperm[mut ..k].reverse()
}
fn work(mut perm: Perm, n: uint, max: uint) -> (i32, i32) {
copy_memory(buf.as_mut_slice(), alu);
let buf_len = buf.len();
- copy_memory(buf.slice_mut(alu_len, buf_len),
- alu.slice_to(LINE_LEN));
+ copy_memory(buf[mut alu_len..buf_len],
+ alu[..LINE_LEN]);
let mut pos = 0;
let mut bytes;
for i in range(0u, chars_left) {
buf[i] = self.nextc();
}
- self.out.write(buf.slice_to(chars_left))
+ self.out.write(buf[..chars_left])
}
}
}
n -= nb;
line[nb] = '\n' as u8;
- wr.write(line.slice_to(nb + 1));
+ wr.write(line[..nb+1]);
}
}
let len = bb.len();
while ii < len - (nn - 1u) {
- it(bb.slice(ii, ii+nn));
+ it(bb[ii..ii+nn]);
ii += 1u;
}
- return Vec::from_slice(bb.slice(len - (nn - 1u), len));
+ return Vec::from_slice(bb[len - (nn - 1u)..len]);
}
fn make_sequence_processor(sz: uint,
// Pull first frame.
for _ in range(0, frame) {
code = code.push_char(input[0]);
- input = input.slice_from(1);
+ input = input[1..];
}
frequencies.lookup(code, BumpCallback);
while input.len() != 0 && input[0] != ('>' as u8) {
code = code.rotate(input[0], frame);
frequencies.lookup(code, BumpCallback);
- input = input.slice_from(1);
+ input = input[1..];
}
frequencies
}
Some(c) => c
};
let len = seq.len();
- let seq = seq.slice_mut(begin + 1, len - 1);
+ let seq = seq[mut begin+1..len-1];
// arrange line breaks
let len = seq.len();
fn main() {
let mut array = [1, 2, 3];
//~^ ERROR cannot determine a type for this local variable: cannot determine the type of this integ
- let pie_slice = array.slice(1, 2);
+ let pie_slice = array[1..2];
}
let empty: &[i64] = &[];
let singleton: &[i64] = &[1];
let multiple: &[i64] = &[2, 3, 4, 5];
- let slice_of_slice = multiple.slice(1,3);
+ let slice_of_slice = multiple[1..3];
let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
// except according to those terms.
fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] {
- v.slice(1, 5)
+ v[1..5]
}
pub fn main() {}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v.slice(i, j) }
+fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v[i..j] }
pub fn main() {}
let abc = [1i, 2, 3];
let tf = [true, false];
let x = [(), ()];
- let slice = x.slice(0,1);
+ let slice = x[0..1];
let z = box(GC) x;
assert_repr_eq(abc, "[1, 2, 3]".to_string());