rollup merge of #23886: demelev/remove_as_slice_usage

This commit is contained in:
Alex Crichton 2015-03-31 10:15:35 -07:00
commit 6d2c640cf0
24 changed files with 41 additions and 42 deletions

View file

@ -1333,7 +1333,7 @@ mod tests {
check!(fs::copy(&input, &out));
let mut v = Vec::new();
check!(check!(File::open(&out)).read_to_end(&mut v));
assert_eq!(v.as_slice(), b"hello");
assert_eq!(&v[..], b"hello");
assert_eq!(check!(input.metadata()).permissions(),
check!(out.metadata()).permissions());
@ -1628,7 +1628,7 @@ mod tests {
check!(check!(File::create(&tmpdir.join("test"))).write(&bytes));
let mut v = Vec::new();
check!(check!(File::open(&tmpdir.join("test"))).read_to_end(&mut v));
assert!(v == bytes.as_slice());
assert!(v == &bytes[..]);
}
#[test]

View file

@ -281,19 +281,19 @@ mod tests {
#[test]
fn test_slice_reader() {
let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = &mut in_buf.as_slice();
let mut reader = &mut &in_buf[..];
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
let mut buf = [0];
assert_eq!(reader.read(&mut buf), Ok(1));
assert_eq!(reader.len(), 7);
let b: &[_] = &[0];
assert_eq!(buf.as_slice(), b);
assert_eq!(buf, b);
let mut buf = [0; 4];
assert_eq!(reader.read(&mut buf), Ok(4));
assert_eq!(reader.len(), 3);
let b: &[_] = &[1, 2, 3, 4];
assert_eq!(buf.as_slice(), b);
assert_eq!(buf, b);
assert_eq!(reader.read(&mut buf), Ok(3));
let b: &[_] = &[5, 6, 7];
assert_eq!(&buf[..3], b);
@ -303,7 +303,7 @@ mod tests {
#[test]
fn test_buf_reader() {
let in_buf = vec![0, 1, 2, 3, 4, 5, 6, 7];
let mut reader = Cursor::new(in_buf.as_slice());
let mut reader = Cursor::new(&in_buf[..]);
let mut buf = [];
assert_eq!(reader.read(&mut buf), Ok(0));
assert_eq!(reader.position(), 0);

View file

@ -1639,7 +1639,7 @@ mod test {
check!(File::create(&tmpdir.join("test")).write(&bytes));
let actual = check!(File::open(&tmpdir.join("test")).read_to_end());
assert!(actual == bytes.as_slice());
assert!(actual == &bytes[..]);
}
#[test]

View file

@ -744,7 +744,7 @@ mod test {
wr.write(&[5; 10]).unwrap();
}
}
assert_eq!(buf.as_slice(), [5; 100].as_slice());
assert_eq!(buf.as_ref(), [5; 100].as_ref());
});
}

View file

@ -435,7 +435,7 @@ pub struct ParseError;
/// let tcp_l = TcpListener::bind("localhost:12345");
///
/// let mut udp_s = UdpSocket::bind(("127.0.0.1", 23451)).unwrap();
/// udp_s.send_to([7, 7, 7].as_slice(), (Ipv4Addr(127, 0, 0, 1), 23451));
/// udp_s.send_to([7, 7, 7].as_ref(), (Ipv4Addr(127, 0, 0, 1), 23451));
/// }
/// ```
pub trait ToSocketAddr {

View file

@ -376,8 +376,8 @@ impl Command {
/// };
///
/// println!("status: {}", output.status);
/// println!("stdout: {}", String::from_utf8_lossy(output.output.as_slice()));
/// println!("stderr: {}", String::from_utf8_lossy(output.error.as_slice()));
/// println!("stdout: {}", String::from_utf8_lossy(output.output.as_ref()));
/// println!("stderr: {}", String::from_utf8_lossy(output.error.as_ref()));
/// ```
pub fn output(&self) -> IoResult<ProcessOutput> {
self.spawn().and_then(|p| p.wait_with_output())

View file

@ -311,7 +311,7 @@ pub fn split_paths<T: BytesContainer>(unparsed: T) -> Vec<Path> {
/// let key = "PATH";
/// let mut paths = os::getenv_as_bytes(key).map_or(Vec::new(), os::split_paths);
/// paths.push(Path::new("/home/xyz/bin"));
/// os::setenv(key, os::join_paths(paths.as_slice()).unwrap());
/// os::setenv(key, os::join_paths(&paths[..]).unwrap());
/// ```
#[unstable(feature = "os")]
pub fn join_paths<T: BytesContainer>(paths: &[T]) -> Result<Vec<u8>, &'static str> {

View file

@ -678,7 +678,7 @@ mod tests {
fn test_process_output_output() {
let Output {status, stdout, stderr}
= Command::new("echo").arg("hello").output().unwrap();
let output_str = str::from_utf8(stdout.as_slice()).unwrap();
let output_str = str::from_utf8(&stdout[..]).unwrap();
assert!(status.success());
assert_eq!(output_str.trim().to_string(), "hello");
@ -720,7 +720,7 @@ mod tests {
let prog = Command::new("echo").arg("hello").stdout(Stdio::piped())
.spawn().unwrap();
let Output {status, stdout, stderr} = prog.wait_with_output().unwrap();
let output_str = str::from_utf8(stdout.as_slice()).unwrap();
let output_str = str::from_utf8(&stdout[..]).unwrap();
assert!(status.success());
assert_eq!(output_str.trim().to_string(), "hello");
@ -855,7 +855,7 @@ mod tests {
cmd.env("PATH", &p);
}
let result = cmd.output().unwrap();
let output = String::from_utf8_lossy(result.stdout.as_slice()).to_string();
let output = String::from_utf8_lossy(&result.stdout[..]).to_string();
assert!(output.contains("RUN_TEST_NEW_ENV=123"),
"didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);
@ -864,7 +864,7 @@ mod tests {
#[test]
fn test_add_to_env() {
let result = env_cmd().env("RUN_TEST_NEW_ENV", "123").output().unwrap();
let output = String::from_utf8_lossy(result.stdout.as_slice()).to_string();
let output = String::from_utf8_lossy(&result.stdout[..]).to_string();
assert!(output.contains("RUN_TEST_NEW_ENV=123"),
"didn't find RUN_TEST_NEW_ENV inside of:\n\n{}", output);