Use slice syntax instead of slice_to, etc.

This commit is contained in:
Nick Cameron
2014-09-24 23:41:09 +12:00
parent a70a0374e2
commit 40b9f5ded5
81 changed files with 331 additions and 363 deletions

View File

@@ -235,7 +235,7 @@ use os;
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;
@@ -575,7 +575,7 @@ pub trait Reader {
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 {
@@ -1111,8 +1111,8 @@ pub trait Writer {
#[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`.
@@ -1496,7 +1496,7 @@ pub trait Buffer: Reader {
};
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
}
@@ -1528,14 +1528,14 @@ pub trait Buffer: Reader {
{
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))
}