diff options
| author | Daniel Micay <danielmicay@gmail.com> | 2013-07-08 01:42:07 -0700 |
|---|---|---|
| committer | Daniel Micay <danielmicay@gmail.com> | 2013-07-08 01:42:07 -0700 |
| commit | 44770ae3a8001de38b33e449889c6444808941fc (patch) | |
| tree | 35b19c50d284bb5a25a3259692dc3783ec95c704 /src/libstd | |
| parent | 96ae000812079b284011571dc18fed0d1fb433d8 (diff) | |
| parent | 641aec74076f8c5735a7d379753194f877866525 (diff) | |
| download | rust-44770ae3a8001de38b33e449889c6444808941fc.tar.gz rust-44770ae3a8001de38b33e449889c6444808941fc.zip | |
Merge pull request #7595 from thestinger/iterator
remove some method resolve workarounds
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/iterator.rs | 26 | ||||
| -rw-r--r-- | src/libstd/run.rs | 2 | ||||
| -rw-r--r-- | src/libstd/str.rs | 2 | ||||
| -rw-r--r-- | src/libstd/task/local_data_priv.rs | 4 | ||||
| -rw-r--r-- | src/libstd/vec.rs | 4 |
5 files changed, 19 insertions, 19 deletions
diff --git a/src/libstd/iterator.rs b/src/libstd/iterator.rs index b164bcbd28b..8094b238749 100644 --- a/src/libstd/iterator.rs +++ b/src/libstd/iterator.rs @@ -338,16 +338,16 @@ pub trait IteratorUtil<A> { /// ~~~ {.rust} /// let a = [1, 2, 3, 4, 5]; /// let mut it = a.iter(); - /// assert!(it.any_(|&x| *x == 3)); - /// assert!(!it.any_(|&x| *x == 3)); + /// assert!(it.any(|&x| *x == 3)); + /// assert!(!it.any(|&x| *x == 3)); /// ~~~ - fn any_(&mut self, f: &fn(A) -> bool) -> bool; + fn any(&mut self, f: &fn(A) -> bool) -> bool; /// Return the first element satisfying the specified predicate fn find_(&mut self, predicate: &fn(&A) -> bool) -> Option<A>; /// Return the index of the first element satisfying the specified predicate - fn position_(&mut self, predicate: &fn(A) -> bool) -> Option<uint>; + fn position(&mut self, predicate: &fn(A) -> bool) -> Option<uint>; /// Count the number of elements satisfying the specified predicate fn count(&mut self, predicate: &fn(A) -> bool) -> uint; @@ -504,7 +504,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { } #[inline] - fn any_(&mut self, f: &fn(A) -> bool) -> bool { + fn any(&mut self, f: &fn(A) -> bool) -> bool { for self.advance |x| { if f(x) { return true; } } false } @@ -520,7 +520,7 @@ impl<A, T: Iterator<A>> IteratorUtil<A> for T { /// Return the index of the first element satisfying the specified predicate #[inline] - fn position_(&mut self, predicate: &fn(A) -> bool) -> Option<uint> { + fn position(&mut self, predicate: &fn(A) -> bool) -> Option<uint> { let mut i = 0; for self.advance |x| { if predicate(x) { @@ -1368,10 +1368,10 @@ mod tests { #[test] fn test_any() { let v = ~&[1, 2, 3, 4, 5]; - assert!(v.iter().any_(|&x| x < 10)); - assert!(v.iter().any_(|&x| x.is_even())); - assert!(!v.iter().any_(|&x| x > 100)); - assert!(!v.slice(0, 0).iter().any_(|_| fail!())); + assert!(v.iter().any(|&x| x < 10)); + assert!(v.iter().any(|&x| x.is_even())); + assert!(!v.iter().any(|&x| x > 100)); + assert!(!v.slice(0, 0).iter().any(|_| fail!())); } #[test] @@ -1385,9 +1385,9 @@ mod tests { #[test] fn test_position() { let v = &[1, 3, 9, 27, 103, 14, 11]; - assert_eq!(v.iter().position_(|x| *x & 1 == 0).unwrap(), 5); - assert_eq!(v.iter().position_(|x| *x % 3 == 0).unwrap(), 1); - assert!(v.iter().position_(|x| *x % 12 == 0).is_none()); + assert_eq!(v.iter().position(|x| *x & 1 == 0).unwrap(), 5); + assert_eq!(v.iter().position(|x| *x % 3 == 0).unwrap(), 1); + assert!(v.iter().position(|x| *x % 12 == 0).is_none()); } #[test] diff --git a/src/libstd/run.rs b/src/libstd/run.rs index df15111a91f..7e051b62171 100644 --- a/src/libstd/run.rs +++ b/src/libstd/run.rs @@ -587,7 +587,7 @@ pub fn make_command_line(prog: &str, args: &[~str]) -> ~str { return cmd; fn append_arg(cmd: &mut ~str, arg: &str) { - let quote = arg.iter().any_(|c| c == ' ' || c == '\t'); + let quote = arg.iter().any(|c| c == ' ' || c == '\t'); if quote { cmd.push_char('"'); } diff --git a/src/libstd/str.rs b/src/libstd/str.rs index 748d5f05aae..3ecafa46a9c 100644 --- a/src/libstd/str.rs +++ b/src/libstd/str.rs @@ -278,7 +278,7 @@ impl CharEq for extern "Rust" fn(char) -> bool { impl<'self, C: CharEq> CharEq for &'self [C] { #[inline] fn matches(&self, c: char) -> bool { - self.iter().any_(|m| m.matches(c)) + self.iter().any(|m| m.matches(c)) } fn only_ascii(&self) -> bool { diff --git a/src/libstd/task/local_data_priv.rs b/src/libstd/task/local_data_priv.rs index 0956b76c970..8dd96df4545 100644 --- a/src/libstd/task/local_data_priv.rs +++ b/src/libstd/task/local_data_priv.rs @@ -142,7 +142,7 @@ unsafe fn local_data_lookup<T: 'static>( -> Option<(uint, *libc::c_void)> { let key_value = key_to_key_value(key); - let map_pos = (*map).iter().position_(|entry| + let map_pos = (*map).iter().position(|entry| match *entry { Some((k,_,_)) => k == key_value, None => false @@ -215,7 +215,7 @@ pub unsafe fn local_set<T: 'static>( } None => { // Find an empty slot. If not, grow the vector. - match (*map).iter().position_(|x| x.is_none()) { + match (*map).iter().position(|x| x.is_none()) { Some(empty_index) => { map[empty_index] = new_entry; } None => { map.push(new_entry); } } diff --git a/src/libstd/vec.rs b/src/libstd/vec.rs index effbc008b6a..84e4358a496 100644 --- a/src/libstd/vec.rs +++ b/src/libstd/vec.rs @@ -191,7 +191,7 @@ impl<'self, T> Iterator<&'self [T]> for VecSplitIterator<'self, T> { return Some(self.v); } - match self.v.iter().position_(|x| (self.pred)(x)) { + match self.v.iter().position(|x| (self.pred)(x)) { None => { self.finished = true; Some(self.v) @@ -1010,7 +1010,7 @@ impl<'self,T:Eq> ImmutableEqVector<T> for &'self [T] { /// Find the first index containing a matching value #[inline] fn position_elem(&self, x: &T) -> Option<uint> { - self.iter().position_(|y| *x == *y) + self.iter().position(|y| *x == *y) } /// Find the last index containing a matching value |
