diff options
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/fs.rs | 4 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 12 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 13 |
3 files changed, 12 insertions, 17 deletions
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index caff7d5e4c5..d49c56b4704 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -999,9 +999,9 @@ mod test { 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_owned() + n => str::from_utf8(read_buf.slice_to(n)).unwrap().to_string() }; - assert_eq!(read_str, message.to_owned()); + assert_eq!(read_str.as_slice(), message); } check!(unlink(filename)); }) diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index 6ac092fd8c6..0df2bb0f57c 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -705,9 +705,9 @@ pub trait Reader { /// UTF-8 bytes. fn read_to_string(&mut self) -> IoResult<String> { self.read_to_end().and_then(|s| { - match str::from_utf8(s.as_slice()) { - Some(s) => Ok(String::from_str(s)), - None => Err(standard_error(InvalidInput)), + match String::from_utf8(s) { + Ok(s) => Ok(s), + Err(_) => Err(standard_error(InvalidInput)), } }) } @@ -1440,9 +1440,9 @@ pub trait Buffer: Reader { /// valid UTF-8 sequence of bytes. fn read_line(&mut self) -> IoResult<String> { self.read_until('\n' as u8).and_then(|line| - match str::from_utf8(line.as_slice()) { - Some(s) => Ok(String::from_str(s)), - None => Err(standard_error(InvalidInput)), + match String::from_utf8(line) { + Ok(s) => Ok(s), + Err(_) => Err(standard_error(InvalidInput)), } ) } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index 07574b72645..bc0140a358c 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -813,8 +813,7 @@ mod tests { use os; let prog = pwd_cmd().spawn().unwrap(); - let output = str::from_utf8(prog.wait_with_output().unwrap() - .output.as_slice()).unwrap().to_string(); + let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap(); let parent_dir = os::getcwd(); let child_dir = Path::new(output.as_slice().trim()); @@ -832,8 +831,7 @@ mod tests { let parent_dir = os::getcwd().dir_path(); let prog = pwd_cmd().cwd(&parent_dir).spawn().unwrap(); - let output = str::from_utf8(prog.wait_with_output().unwrap() - .output.as_slice()).unwrap().to_string(); + let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap(); let child_dir = Path::new(output.as_slice().trim().into_string()); let parent_stat = parent_dir.stat().unwrap(); @@ -867,8 +865,7 @@ mod tests { if running_on_valgrind() { return; } let prog = env_cmd().spawn().unwrap(); - let output = str::from_utf8(prog.wait_with_output().unwrap() - .output.as_slice()).unwrap().to_string(); + let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap(); let r = os::env(); for &(ref k, ref v) in r.iter() { @@ -884,9 +881,7 @@ mod tests { if running_on_valgrind() { return; } let mut prog = env_cmd().spawn().unwrap(); - let output = str::from_utf8(prog.wait_with_output() - .unwrap().output.as_slice()) - .unwrap().to_string(); + let output = String::from_utf8(prog.wait_with_output().unwrap().output).unwrap(); let r = os::env(); for &(ref k, ref v) in r.iter() { |
