diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 14:31:55 -0800 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-02-18 14:31:55 -0800 |
| commit | c07ec507e26ed5ecde63bf7138b09592d9001fb2 (patch) | |
| tree | 25b5b50cf3c9a1b73455e3cc629acd6abb3be990 /src/libstd | |
| parent | c5fddd81ab47ddbfd5525210fb1536472de399b8 (diff) | |
| parent | d2f54e663400b98c368710669ad9a966fa950803 (diff) | |
| download | rust-c07ec507e26ed5ecde63bf7138b09592d9001fb2.tar.gz rust-c07ec507e26ed5ecde63bf7138b09592d9001fb2.zip | |
rollup merge of #22287: Ryman/purge_carthographers
This overlaps with #22276 (I left make check running overnight) but covers a number of additional cases and has a few rewrites where the clones are not even necessary. This also implements `RandomAccessIterator` for `iter::Cloned` cc @steveklabnik, you may want to glance at this before #22281 gets the bors treatment
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/env.rs | 8 | ||||
| -rw-r--r-- | src/libstd/old_path/posix.rs | 4 | ||||
| -rw-r--r-- | src/libstd/old_path/windows.rs | 4 | ||||
| -rw-r--r-- | src/libstd/rand/mod.rs | 2 |
4 files changed, 9 insertions, 9 deletions
diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 93dc3efe2c4..8676586e7dc 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -926,7 +926,7 @@ mod tests { #[cfg(unix)] fn join_paths_unix() { fn test_eq(input: &[&str], output: &str) -> bool { - &*join_paths(input.iter().map(|s| *s)).unwrap() == + &*join_paths(input.iter().cloned()).unwrap() == OsStr::from_str(output) } @@ -935,14 +935,14 @@ mod tests { "/bin:/usr/bin:/usr/local/bin")); assert!(test_eq(&["", "/bin", "", "", "/usr/bin", ""], ":/bin:::/usr/bin:")); - assert!(join_paths(["/te:st"].iter().map(|s| *s)).is_err()); + assert!(join_paths(["/te:st"].iter().cloned()).is_err()); } #[test] #[cfg(windows)] fn join_paths_windows() { fn test_eq(input: &[&str], output: &str) -> bool { - &*join_paths(input.iter().map(|s| *s)).unwrap() == + &*join_paths(input.iter().cloned()).unwrap() == OsStr::from_str(output) } @@ -953,6 +953,6 @@ mod tests { r";c:\windows;;;c:\;")); assert!(test_eq(&[r"c:\te;st", r"c:\"], r#""c:\te;st";c:\"#)); - assert!(join_paths([r#"c:\te"st"#].iter().map(|s| *s)).is_err()); + assert!(join_paths([r#"c:\te"st"#].iter().cloned()).is_err()); } } diff --git a/src/libstd/old_path/posix.rs b/src/libstd/old_path/posix.rs index 440d17cfd50..35bffa689f3 100644 --- a/src/libstd/old_path/posix.rs +++ b/src/libstd/old_path/posix.rs @@ -1172,7 +1172,7 @@ mod tests { let exp: &[&[u8]] = &[$($exp),*]; assert_eq!(comps, exp); let comps = path.components().rev().collect::<Vec<&[u8]>>(); - let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>(); + let exp = exp.iter().rev().cloned().collect::<Vec<&[u8]>>(); assert_eq!(comps, exp) } ) @@ -1204,7 +1204,7 @@ mod tests { let exp: &[Option<&str>] = &$exp; assert_eq!(comps, exp); let comps = path.str_components().rev().collect::<Vec<Option<&str>>>(); - let exp = exp.iter().rev().map(|&x|x).collect::<Vec<Option<&str>>>(); + let exp = exp.iter().rev().cloned().collect::<Vec<Option<&str>>>(); assert_eq!(comps, exp); } ) diff --git a/src/libstd/old_path/windows.rs b/src/libstd/old_path/windows.rs index 07c5e10992b..c9d6eeda762 100644 --- a/src/libstd/old_path/windows.rs +++ b/src/libstd/old_path/windows.rs @@ -2226,7 +2226,7 @@ mod tests { assert_eq!(comps, exp); let comps = path.str_components().rev().map(|x|x.unwrap()) .collect::<Vec<&str>>(); - let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&str>>(); + let exp = exp.iter().rev().cloned().collect::<Vec<&str>>(); assert_eq!(comps, exp); } ); @@ -2282,7 +2282,7 @@ mod tests { let exp: &[&[u8]] = &$exp; assert_eq!(comps, exp); let comps = path.components().rev().collect::<Vec<&[u8]>>(); - let exp = exp.iter().rev().map(|&x|x).collect::<Vec<&[u8]>>(); + let exp = exp.iter().rev().cloned().collect::<Vec<&[u8]>>(); assert_eq!(comps, exp); } ) diff --git a/src/libstd/rand/mod.rs b/src/libstd/rand/mod.rs index 8f9e966cbb2..5b888c7612d 100644 --- a/src/libstd/rand/mod.rs +++ b/src/libstd/rand/mod.rs @@ -547,7 +547,7 @@ mod test { #[test] fn test_choose() { let mut r = thread_rng(); - assert_eq!(r.choose(&[1, 1, 1]).map(|&x|x), Some(1)); + assert_eq!(r.choose(&[1, 1, 1]).cloned(), Some(1)); let v: &[int] = &[]; assert_eq!(r.choose(v), None); |
