diff options
| author | bors <bors@rust-lang.org> | 2014-12-08 02:32:31 +0000 | 
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-12-08 02:32:31 +0000 | 
| commit | 83a44c7fa676b4e5e546ce3d4624e585f9a1e899 (patch) | |
| tree | 36d7db1d2567d86816d4ac6a1ec86276974dbc65 /src/libstd/io/mod.rs | |
| parent | 8bca470c5acf13aa20022a2c462a89f72de721fc (diff) | |
| parent | 1fea900de7f11d665086141806246842c03b9fc5 (diff) | |
| download | rust-83a44c7fa676b4e5e546ce3d4624e585f9a1e899.tar.gz rust-83a44c7fa676b4e5e546ce3d4624e585f9a1e899.zip  | |
auto merge of #19378 : japaric/rust/no-as-slice, r=alexcrichton
Now that we have an overloaded comparison (`==`) operator, and that `Vec`/`String` deref to `[T]`/`str` on method calls, many `as_slice()`/`as_mut_slice()`/`to_string()` calls have become redundant. This patch removes them. These were the most common patterns: - `assert_eq(test_output.as_slice(), "ground truth")` -> `assert_eq(test_output, "ground truth")` - `assert_eq(test_output, "ground truth".to_string())` -> `assert_eq(test_output, "ground truth")` - `vec.as_mut_slice().sort()` -> `vec.sort()` - `vec.as_slice().slice(from, to)` -> `vec.slice(from_to)` --- Note that e.g. `a_string.push_str(b_string.as_slice())` has been left untouched in this PR, since we first need to settle down whether we want to favor the `&*b_string` or the `b_string[]` notation. This is rebased on top of #19167 cc @alexcrichton @aturon
Diffstat (limited to 'src/libstd/io/mod.rs')
| -rw-r--r-- | src/libstd/io/mod.rs | 22 | 
1 files changed, 11 insertions, 11 deletions
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index e0857fd27ff..d43a7a66c5b 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -240,8 +240,8 @@ use boxed::Box; use result::Result; use result::Result::{Ok, Err}; use sys; -use slice::{AsSlice, SlicePrelude}; -use str::{Str, StrPrelude}; +use slice::SlicePrelude; +use str::StrPrelude; use str; use string::String; use uint; @@ -318,7 +318,7 @@ impl IoError { pub fn from_errno(errno: uint, detail: bool) -> IoError { let mut err = sys::decode_error(errno as i32); if detail && err.kind == OtherIoError { - err.detail = Some(os::error_string(errno).as_slice().chars() + err.detail = Some(os::error_string(errno).chars() .map(|c| c.to_lowercase()).collect()) } err @@ -2007,14 +2007,14 @@ mod tests { fn test_show() { use super::*; - assert_eq!(format!("{}", USER_READ), "0400".to_string()); - assert_eq!(format!("{}", USER_FILE), "0644".to_string()); - assert_eq!(format!("{}", USER_EXEC), "0755".to_string()); - assert_eq!(format!("{}", USER_RWX), "0700".to_string()); - assert_eq!(format!("{}", GROUP_RWX), "0070".to_string()); - assert_eq!(format!("{}", OTHER_RWX), "0007".to_string()); - assert_eq!(format!("{}", ALL_PERMISSIONS), "0777".to_string()); - assert_eq!(format!("{}", USER_READ | USER_WRITE | OTHER_WRITE), "0602".to_string()); + assert_eq!(format!("{}", USER_READ), "0400"); + assert_eq!(format!("{}", USER_FILE), "0644"); + assert_eq!(format!("{}", USER_EXEC), "0755"); + assert_eq!(format!("{}", USER_RWX), "0700"); + assert_eq!(format!("{}", GROUP_RWX), "0070"); + assert_eq!(format!("{}", OTHER_RWX), "0007"); + assert_eq!(format!("{}", ALL_PERMISSIONS), "0777"); + assert_eq!(format!("{}", USER_READ | USER_WRITE | OTHER_WRITE), "0602"); } fn _ensure_buffer_is_object_safe<T: Buffer>(x: &T) -> &Buffer {  | 
