Skip to content

Rename from_iterator to from_iter for consistency. #13220

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 31, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/doc/guide-container.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ vectors is as follows:

~~~ {.ignore}
impl<A> FromIterator<A> for ~[A] {
pub fn from_iterator<T: Iterator<A>>(iterator: &mut T) -> ~[A] {
pub fn from_iter<T: Iterator<A>>(iterator: &mut T) -> ~[A] {
let (lower, _) = iterator.size_hint();
let mut xs = with_capacity(lower);
for x in iterator {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ impl<A> DoubleEndedIterator<A> for MoveItems<A> {
}

impl<A> FromIterator<A> for DList<A> {
fn from_iterator<T: Iterator<A>>(iterator: T) -> DList<A> {
fn from_iter<T: Iterator<A>>(iterator: T) -> DList<A> {
let mut ret = DList::new();
ret.extend(iterator);
ret
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/hashmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,7 +1356,7 @@ pub type Values<'a, K, V> =
iter::Map<'static, (&'a K, &'a V), &'a V, Entries<'a, K, V>>;

impl<K: TotalEq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
fn from_iterator<T: Iterator<(K, V)>>(iter: T) -> HashMap<K, V, H> {
fn from_iter<T: Iterator<(K, V)>>(iter: T) -> HashMap<K, V, H> {
let (lower, _) = iter.size_hint();
let mut map = HashMap::with_capacity_and_hasher(lower, Default::default());
map.extend(iter);
Expand Down Expand Up @@ -1540,7 +1540,7 @@ impl<T: TotalEq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T,
}

impl<T: TotalEq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
fn from_iterator<I: Iterator<T>>(iter: I) -> HashSet<T, H> {
fn from_iter<I: Iterator<T>>(iter: I) -> HashSet<T, H> {
let (lower, _) = iter.size_hint();
let mut set = HashSet::with_capacity_and_hasher(lower, Default::default());
set.extend(iter);
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/priority_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
}

impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
fn from_iterator<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
let mut q = PriorityQueue::new();
q.extend(iter);
q
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/ringbuf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ impl<A: Eq> Eq for RingBuf<A> {
}

impl<A> FromIterator<A> for RingBuf<A> {
fn from_iterator<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
fn from_iter<T: Iterator<A>>(iterator: T) -> RingBuf<A> {
let (lower, _) = iterator.size_hint();
let mut deq = RingBuf::with_capacity(lower);
deq.extend(iterator);
Expand Down Expand Up @@ -778,7 +778,7 @@ mod tests {
}

#[test]
fn test_from_iterator() {
fn test_from_iter() {
use std::iter;
let v = ~[1,2,3,4,5,6,7];
let deq: RingBuf<int> = v.iter().map(|&x| x).collect();
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/treemap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ fn remove<K: TotalOrd, V>(node: &mut Option<~TreeNode<K, V>>,
}

impl<K: TotalOrd, V> FromIterator<(K, V)> for TreeMap<K, V> {
fn from_iterator<T: Iterator<(K, V)>>(iter: T) -> TreeMap<K, V> {
fn from_iter<T: Iterator<(K, V)>>(iter: T) -> TreeMap<K, V> {
let mut map = TreeMap::new();
map.extend(iter);
map
Expand All @@ -988,7 +988,7 @@ impl<K: TotalOrd, V> Extendable<(K, V)> for TreeMap<K, V> {
}

impl<T: TotalOrd> FromIterator<T> for TreeSet<T> {
fn from_iterator<Iter: Iterator<T>>(iter: Iter) -> TreeSet<T> {
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> TreeSet<T> {
let mut set = TreeSet::new();
set.extend(iter);
set
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/trie.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ impl<T> TrieMap<T> {
}

impl<T> FromIterator<(uint, T)> for TrieMap<T> {
fn from_iterator<Iter: Iterator<(uint, T)>>(iter: Iter) -> TrieMap<T> {
fn from_iter<Iter: Iterator<(uint, T)>>(iter: Iter) -> TrieMap<T> {
let mut map = TrieMap::new();
map.extend(iter);
map
Expand Down Expand Up @@ -346,7 +346,7 @@ impl TrieSet {
}

impl FromIterator<uint> for TrieSet {
fn from_iterator<Iter: Iterator<uint>>(iter: Iter) -> TrieSet {
fn from_iter<Iter: Iterator<uint>>(iter: Iter) -> TrieSet {
let mut set = TrieSet::new();
set.extend(iter);
set
Expand Down
6 changes: 3 additions & 3 deletions src/libstd/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ use mem;
/// Conversion from an `Iterator`
pub trait FromIterator<A> {
/// Build a container with elements from an external iterator.
fn from_iterator<T: Iterator<A>>(iterator: T) -> Self;
fn from_iter<T: Iterator<A>>(iterator: T) -> Self;
}

/// A type growable from an `Iterator` implementation
Expand Down Expand Up @@ -460,7 +460,7 @@ pub trait Iterator<A> {
/// ```
#[inline]
fn collect<B: FromIterator<A>>(&mut self) -> B {
FromIterator::from_iterator(self.by_ref())
FromIterator::from_iter(self.by_ref())
}

/// Loops through `n` iterations, returning the `n`th element of the
Expand Down Expand Up @@ -2336,7 +2336,7 @@ mod tests {
#[test]
fn test_counter_from_iter() {
let it = count(0, 5).take(10);
let xs: ~[int] = FromIterator::from_iterator(it);
let xs: ~[int] = FromIterator::from_iter(it);
assert_eq!(xs, ~[0, 5, 10, 15, 20, 25, 30, 35, 40, 45]);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libstd/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ pub fn collect<T, Iter: Iterator<Option<T>>, V: FromIterator<T>>(iter: Iter) ->
}
});

let v: V = FromIterator::from_iterator(iter.by_ref());
let v: V = FromIterator::from_iter(iter.by_ref());

if iter.state {
None
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn collect<T, E, Iter: Iterator<Result<T, E>>, V: FromIterator<T>>(iter: Ite
}
});

let v: V = FromIterator::from_iterator(iter.by_ref());
let v: V = FromIterator::from_iter(iter.by_ref());

match iter.state {
Some(err) => Err(err),
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2891,7 +2891,7 @@ impl<T> Drop for MoveItems<T> {
pub type RevMoveItems<T> = Rev<MoveItems<T>>;

impl<A> FromIterator<A> for ~[A] {
fn from_iterator<T: Iterator<A>>(mut iterator: T) -> ~[A] {
fn from_iter<T: Iterator<A>>(mut iterator: T) -> ~[A] {
let (lower, _) = iterator.size_hint();
let mut xs = with_capacity(lower);
for x in iterator {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3019,7 +3019,7 @@ impl Clone for ~str {

impl FromIterator<char> for ~str {
#[inline]
fn from_iterator<T: Iterator<char>>(iterator: T) -> ~str {
fn from_iter<T: Iterator<char>>(iterator: T) -> ~str {
let (lower, _) = iterator.size_hint();
let mut buf = with_capacity(lower);
buf.extend(iterator);
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ impl<T:Clone> Clone for Vec<T> {
}

impl<T> FromIterator<T> for Vec<T> {
fn from_iterator<I:Iterator<T>>(mut iterator: I) -> Vec<T> {
fn from_iter<I:Iterator<T>>(mut iterator: I) -> Vec<T> {
let (lower, _) = iterator.size_hint();
let mut vector = Vec::with_capacity(lower);
for element in iterator {
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/owned_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<T> Container for OwnedSlice<T> {
}

impl<T> FromIterator<T> for OwnedSlice<T> {
fn from_iterator<I: Iterator<T>>(mut iter: I) -> OwnedSlice<T> {
fn from_iter<I: Iterator<T>>(mut iter: I) -> OwnedSlice<T> {
OwnedSlice::from_vec(iter.collect())
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/libsyntax/util/small_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl<T> Container for SmallVector<T> {
}

impl<T> FromIterator<T> for SmallVector<T> {
fn from_iterator<I: Iterator<T>>(iter: I) -> SmallVector<T> {
fn from_iter<I: Iterator<T>>(iter: I) -> SmallVector<T> {
let mut v = Zero;
v.extend(iter);
v
Expand Down Expand Up @@ -167,7 +167,7 @@ mod test {
}

#[test]
fn test_from_iterator() {
fn test_from_iter() {
let v: SmallVector<int> = (vec!(1, 2, 3)).move_iter().collect();
assert_eq!(3, v.len());
assert_eq!(&1, v.get(0));
Expand Down