libstd: remove unnecessary as_slice() calls

This commit is contained in:
Jorge Aparicio 2014-11-27 14:43:55 -05:00
parent 09f7713dd4
commit 60338d91c4
19 changed files with 118 additions and 121 deletions

View file

@ -376,8 +376,8 @@ pub fn readlink(p: &Path) -> IoResult<Path> {
libc::VOLUME_NAME_DOS)
});
let ret = match ret {
Some(ref s) if s.as_slice().starts_with(r"\\?\") => { // "
Ok(Path::new(s.as_slice().slice_from(4)))
Some(ref s) if s.starts_with(r"\\?\") => { // "
Ok(Path::new(s.slice_from(4)))
}
Some(s) => Ok(Path::new(s)),
None => Err(super::last_error()),

View file

@ -223,7 +223,7 @@ impl Process {
with_envp(cfg.env(), |envp| {
with_dirp(cfg.cwd(), |dirp| {
let mut cmd_str: Vec<u16> = cmd_str.as_slice().utf16_units().collect();
let mut cmd_str: Vec<u16> = cmd_str.utf16_units().collect();
cmd_str.push(0);
let created = CreateProcessW(ptr::null(),
cmd_str.as_mut_ptr(),
@ -433,7 +433,7 @@ fn with_envp<K, V, T>(env: Option<&collections::HashMap<K, V>>,
let kv = format!("{}={}",
pair.ref0().container_as_str().unwrap(),
pair.ref1().container_as_str().unwrap());
blk.extend(kv.as_slice().utf16_units());
blk.extend(kv.utf16_units());
blk.push(0);
}

View file

@ -113,7 +113,7 @@ impl TTY {
pub fn write(&mut self, buf: &[u8]) -> IoResult<()> {
let utf16 = match from_utf8(buf) {
Some(utf8) => {
utf8.as_slice().utf16_units().collect::<Vec<u16>>()
utf8.utf16_units().collect::<Vec<u16>>()
}
None => return Err(invalid_encoding()),
};