diff options
| author | bors <bors@rust-lang.org> | 2015-06-11 18:10:08 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-06-11 18:10:08 +0000 |
| commit | b5b3a99f84f2b4dbf9495dccd7112c74f4357acc (patch) | |
| tree | cfdba2e1880f58d4e2c29e06fac2de4f76a34108 /src/libstd | |
| parent | deff2f50a97342c8b2f92a124ded2d2ead7b2996 (diff) | |
| parent | d7f5fa4636b12c3dadd626e708ec7cef654faf54 (diff) | |
| download | rust-b5b3a99f84f2b4dbf9495dccd7112c74f4357acc.tar.gz rust-b5b3a99f84f2b4dbf9495dccd7112c74f4357acc.zip | |
Auto merge of #26190 - Veedrac:no-iter, r=alexcrichton
Pull request for #26188.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/ascii.rs | 2 | ||||
| -rw-r--r-- | src/libstd/collections/hash/map.rs | 2 | ||||
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 10 | ||||
| -rw-r--r-- | src/libstd/collections/mod.rs | 7 | ||||
| -rw-r--r-- | src/libstd/dynamic_lib.rs | 2 | ||||
| -rw-r--r-- | src/libstd/env.rs | 2 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 2 | ||||
| -rw-r--r-- | src/libstd/net/parser.rs | 2 | ||||
| -rw-r--r-- | src/libstd/sys/windows/fs.rs | 2 | ||||
| -rw-r--r-- | src/libstd/thread/local.rs | 2 |
10 files changed, 17 insertions, 16 deletions
diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index ccc56960b02..b808acb73a1 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -226,7 +226,7 @@ impl AsciiExt for [u8] { #[inline] fn eq_ignore_ascii_case(&self, other: &[u8]) -> bool { self.len() == other.len() && - self.iter().zip(other.iter()).all(|(a, b)| { + self.iter().zip(other).all(|(a, b)| { a.eq_ignore_ascii_case(b) }) } diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index 093218c6e4c..e12814bf77c 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -906,7 +906,7 @@ impl<K, V, S> HashMap<K, V, S> /// *val *= 2; /// } /// - /// for (key, val) in map.iter() { + /// for (key, val) in &map { /// println!("key: {} val: {}", key, val); /// } /// ``` diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 44fc0f7016d..c31a46ada32 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -647,7 +647,7 @@ impl<'a, 'b, T, S> BitOr<&'b HashSet<T, S>> for &'a HashSet<T, S> /// /// let mut i = 0; /// let expected = [1, 2, 3, 4, 5]; - /// for x in set.iter() { + /// for x in &set { /// assert!(expected.contains(x)); /// i += 1; /// } @@ -679,7 +679,7 @@ impl<'a, 'b, T, S> BitAnd<&'b HashSet<T, S>> for &'a HashSet<T, S> /// /// let mut i = 0; /// let expected = [2, 3]; - /// for x in set.iter() { + /// for x in &set { /// assert!(expected.contains(x)); /// i += 1; /// } @@ -711,7 +711,7 @@ impl<'a, 'b, T, S> BitXor<&'b HashSet<T, S>> for &'a HashSet<T, S> /// /// let mut i = 0; /// let expected = [1, 2, 4, 5]; - /// for x in set.iter() { + /// for x in &set { /// assert!(expected.contains(x)); /// i += 1; /// } @@ -743,7 +743,7 @@ impl<'a, 'b, T, S> Sub<&'b HashSet<T, S>> for &'a HashSet<T, S> /// /// let mut i = 0; /// let expected = [1, 2]; - /// for x in set.iter() { + /// for x in &set { /// assert!(expected.contains(x)); /// i += 1; /// } @@ -838,7 +838,7 @@ impl<T, S> IntoIterator for HashSet<T, S> /// let v: Vec<String> = set.into_iter().collect(); /// /// // Will print in an arbitrary order. - /// for x in v.iter() { + /// for x in &v { /// println!("{}", x); /// } /// ``` diff --git a/src/libstd/collections/mod.rs b/src/libstd/collections/mod.rs index 1099bf108f1..4781f2b4754 100644 --- a/src/libstd/collections/mod.rs +++ b/src/libstd/collections/mod.rs @@ -252,6 +252,7 @@ //! contents by-value. This is great when the collection itself is no longer //! needed, and the values are needed elsewhere. Using `extend` with `into_iter` //! is the main way that contents of one collection are moved into another. +//! `extend` automatically calls `into_iter`, and takes any `T: IntoIterator`. //! Calling `collect` on an iterator itself is also a great way to convert one //! collection into another. Both of these methods should internally use the //! capacity management tools discussed in the previous section to do this as @@ -260,7 +261,7 @@ //! ``` //! let mut vec1 = vec![1, 2, 3, 4]; //! let vec2 = vec![10, 20, 30, 40]; -//! vec1.extend(vec2.into_iter()); +//! vec1.extend(vec2); //! ``` //! //! ``` @@ -339,7 +340,7 @@ //! assert_eq!(count.get(&'s'), Some(&8)); //! //! println!("Number of occurrences of each character"); -//! for (char, count) in count.iter() { +//! for (char, count) in &count { //! println!("{}: {}", char, count); //! } //! ``` @@ -362,7 +363,7 @@ //! // Our clients. //! let mut blood_alcohol = BTreeMap::new(); //! -//! for id in orders.into_iter() { +//! for id in orders { //! // If this is the first time we've seen this customer, initialize them //! // with no blood alcohol. Otherwise, just retrieve them. //! let person = blood_alcohol.entry(id).or_insert(Person{id: id, blood_alcohol: 0.0}); diff --git a/src/libstd/dynamic_lib.rs b/src/libstd/dynamic_lib.rs index ebdc049bc7f..1c8e52f1b53 100644 --- a/src/libstd/dynamic_lib.rs +++ b/src/libstd/dynamic_lib.rs @@ -294,7 +294,7 @@ mod dl { let result = match filename { Some(filename) => { let filename_str: Vec<_> = - filename.encode_wide().chain(Some(0).into_iter()).collect(); + filename.encode_wide().chain(Some(0)).collect(); let result = unsafe { LoadLibraryW(filename_str.as_ptr() as *const libc::c_void) }; diff --git a/src/libstd/env.rs b/src/libstd/env.rs index 379c925b575..7f83f0763c6 100644 --- a/src/libstd/env.rs +++ b/src/libstd/env.rs @@ -365,7 +365,7 @@ pub struct JoinPathsError { /// if let Some(path) = env::var_os("PATH") { /// let mut paths = env::split_paths(&path).collect::<Vec<_>>(); /// paths.push(PathBuf::from("/home/xyz/bin")); -/// let new_path = env::join_paths(paths.iter()).unwrap(); +/// let new_path = env::join_paths(paths).unwrap(); /// env::set_var("PATH", &new_path); /// } /// ``` diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 5fbf650dc3f..d8c999f8948 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -78,7 +78,7 @@ pub fn repeat(byte: u8) -> Repeat { Repeat { byte: byte } } #[stable(feature = "rust1", since = "1.0.0")] impl Read for Repeat { fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> { - for slot in buf.iter_mut() { + for slot in &mut *buf { *slot = self.byte; } Ok(buf.len()) diff --git a/src/libstd/net/parser.rs b/src/libstd/net/parser.rs index 69f40d7e7be..b0fadb56f36 100644 --- a/src/libstd/net/parser.rs +++ b/src/libstd/net/parser.rs @@ -63,7 +63,7 @@ impl<'a> Parser<'a> { // Return result of first successful parser fn read_or<T>(&mut self, parsers: &mut [Box<FnMut(&mut Parser) -> Option<T> + 'static>]) -> Option<T> { - for pf in parsers.iter_mut() { + for pf in parsers { match self.read_atomically(|p: &mut Parser| pf(p)) { Some(r) => return Some(r), None => {} diff --git a/src/libstd/sys/windows/fs.rs b/src/libstd/sys/windows/fs.rs index 4401a52d71f..437b2cc6491 100644 --- a/src/libstd/sys/windows/fs.rs +++ b/src/libstd/sys/windows/fs.rs @@ -368,7 +368,7 @@ impl fmt::Debug for File { } pub fn to_utf16(s: &Path) -> Vec<u16> { - s.as_os_str().encode_wide().chain(Some(0).into_iter()).collect() + s.as_os_str().encode_wide().chain(Some(0)).collect() } impl FileAttr { diff --git a/src/libstd/thread/local.rs b/src/libstd/thread/local.rs index cdd7dff0108..69a26cdc490 100644 --- a/src/libstd/thread/local.rs +++ b/src/libstd/thread/local.rs @@ -368,7 +368,7 @@ mod imp { unsafe extern fn run_dtors(mut ptr: *mut u8) { while !ptr.is_null() { let list: Box<List> = Box::from_raw(ptr as *mut List); - for &(ptr, dtor) in &*list { + for &(ptr, dtor) in list.iter() { dtor(ptr); } ptr = DTORS.get(); |
