Skip to content

Ensure Extend is implemented and renamed Extendable to Extend #18475

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 2 commits into from
Nov 8, 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/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ syn keyword rustEnum Ordering
syn keyword rustEnumVariant Less Equal Greater
syn keyword rustTrait Collection Mutable Map MutableMap MutableSeq
syn keyword rustTrait Set MutableSet
syn keyword rustTrait FromIterator Extendable ExactSize
syn keyword rustTrait FromIterator IntoIterator Extend ExactSize
syn keyword rustTrait Iterator DoubleEndedIterator
syn keyword rustTrait RandomAccessIterator CloneableIterator
syn keyword rustTrait OrdIterator MutableDoubleEndedIterator
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ impl<T: Ord> FromIterator<T> for BinaryHeap<T> {
}
}

impl<T: Ord> Extendable<T> for BinaryHeap<T> {
impl<T: Ord> Extend<T> for BinaryHeap<T> {
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
let (lower, _) = iter.size_hint();

Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,7 +835,7 @@ impl FromIterator<bool> for Bitv {
}
}

impl Extendable<bool> for Bitv {
impl Extend<bool> for Bitv {
#[inline]
fn extend<I: Iterator<bool>>(&mut self, mut iterator: I) {
let (min, _) = iterator.size_hint();
Expand Down Expand Up @@ -1014,7 +1014,7 @@ impl FromIterator<bool> for BitvSet {
}
}

impl Extendable<bool> for BitvSet {
impl Extend<bool> for BitvSet {
#[inline]
fn extend<I: Iterator<bool>>(&mut self, iterator: I) {
let &BitvSet(ref mut self_bitv) = self;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for BTreeMap<K, V> {
}
}

impl<K: Ord, V> Extendable<(K, V)> for BTreeMap<K, V> {
impl<K: Ord, V> Extend<(K, V)> for BTreeMap<K, V> {
#[inline]
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
for (k, v) in iter {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/btree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ impl<T: Ord> FromIterator<T> for BTreeSet<T> {
}
}

impl<T: Ord> Extendable<T> for BTreeSet<T> {
impl<T: Ord> Extend<T> for BTreeSet<T> {
#[inline]
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
for elem in iter {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ impl<A> FromIterator<A> for DList<A> {
}
}

impl<A> Extendable<A> for DList<A> {
impl<A> Extend<A> for DList<A> {
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
for elt in iterator { self.push_back(elt); }
}
Expand Down
16 changes: 16 additions & 0 deletions src/libcollections/enum_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,22 @@ impl<E:CLike> Iterator<E> for Items<E> {
}
}

impl<E:CLike> FromIterator<E> for EnumSet<E> {
fn from_iter<I:Iterator<E>>(iterator: I) -> EnumSet<E> {
let mut ret = EnumSet::new();
ret.extend(iterator);
ret
}
}

impl<E:CLike> Extend<E> for EnumSet<E> {
fn extend<I: Iterator<E>>(&mut self, mut iterator: I) {
for element in iterator {
self.insert(element);
}
}
}

#[cfg(test)]
mod test {
use std::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/ring_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -735,7 +735,7 @@ impl<A> FromIterator<A> for RingBuf<A> {
}
}

impl<A> Extendable<A> for RingBuf<A> {
impl<A> Extend<A> for RingBuf<A> {
fn extend<T: Iterator<A>>(&mut self, mut iterator: T) {
for elt in iterator {
self.push_back(elt);
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ impl FromIterator<char> for String {
}
}

#[experimental = "waiting on Extendable stabilization"]
impl Extendable<char> for String {
#[experimental = "waiting on Extend stabilization"]
impl Extend<char> for String {
fn extend<I:Iterator<char>>(&mut self, mut iterator: I) {
for ch in iterator {
self.push(ch)
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/tree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,7 +1260,7 @@ impl<K: Ord, V> FromIterator<(K, V)> for TreeMap<K, V> {
}
}

impl<K: Ord, V> Extendable<(K, V)> for TreeMap<K, V> {
impl<K: Ord, V> Extend<(K, V)> for TreeMap<K, V> {
#[inline]
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
for (k, v) in iter {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/tree/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ impl<T: Ord> FromIterator<T> for TreeSet<T> {
}
}

impl<T: Ord> Extendable<T> for TreeSet<T> {
impl<T: Ord> Extend<T> for TreeSet<T> {
#[inline]
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
for elem in iter {
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/trie/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,7 +628,7 @@ impl<T> FromIterator<(uint, T)> for TrieMap<T> {
}
}

impl<T> Extendable<(uint, T)> for TrieMap<T> {
impl<T> Extend<(uint, T)> for TrieMap<T> {
fn extend<Iter: Iterator<(uint, T)>>(&mut self, mut iter: Iter) {
for (k, v) in iter {
self.insert(k, v);
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/trie/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ impl FromIterator<uint> for TrieSet {
}
}

impl Extendable<uint> for TrieSet {
impl Extend<uint> for TrieSet {
fn extend<Iter: Iterator<uint>>(&mut self, mut iter: Iter) {
for elem in iter {
self.insert(elem);
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,8 @@ impl<T> FromIterator<T> for Vec<T> {
}
}

#[experimental = "waiting on Extendable stability"]
impl<T> Extendable<T> for Vec<T> {
#[experimental = "waiting on Extend stability"]
impl<T> Extend<T> for Vec<T> {
#[inline]
fn extend<I: Iterator<T>>(&mut self, mut iterator: I) {
let (lower, _) = iterator.size_hint();
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/vec_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ impl<V> FromIterator<(uint, V)> for VecMap<V> {
}
}

impl<V> Extendable<(uint, V)> for VecMap<V> {
impl<V> Extend<(uint, V)> for VecMap<V> {
fn extend<Iter: Iterator<(uint, V)>>(&mut self, mut iter: Iter) {
for (k, v) in iter {
self.insert(k, v);
Expand Down
5 changes: 3 additions & 2 deletions src/libcore/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ use num::{Zero, One, CheckedAdd, CheckedSub, Saturating, ToPrimitive, Int};
use ops::{Add, Mul, Sub};
use option::{Option, Some, None};
use uint;
#[deprecated = "renamed to Extend"] pub use self::Extend as Extendable;

/// Conversion from an `Iterator`
pub trait FromIterator<A> {
Expand All @@ -74,8 +75,8 @@ pub trait FromIterator<A> {
}

/// A type growable from an `Iterator` implementation
pub trait Extendable<A>: FromIterator<A> {
/// Extend a container with the elements yielded by an iterator
pub trait Extend<A> {
/// Extend a container with the elements yielded by an arbitrary iterator
fn extend<T: Iterator<A>>(&mut self, iterator: T);
}

Expand Down
2 changes: 1 addition & 1 deletion src/libcore/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub use char::Char;
pub use clone::Clone;
pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
pub use iter::{FromIterator, Extendable};
pub use iter::{FromIterator, Extend};
pub use iter::{Iterator, DoubleEndedIterator, RandomAccessIterator, CloneableIterator};
pub use iter::{OrdIterator, MutableDoubleEndedIterator, ExactSize};
pub use num::{Num, NumCast, CheckedAdd, CheckedSub, CheckedMul};
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/fold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// except according to those terms.

use clean::*;
use std::iter::Extendable;
use std::iter::Extend;
use std::mem::{replace, swap};

pub trait DocFolder {
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/collections/hash/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use cmp::{max, Eq, Equiv, PartialEq};
use default::Default;
use fmt::{mod, Show};
use hash::{Hash, Hasher, RandomSipHasher};
use iter::{mod, Iterator, FromIterator, Extendable};
use iter::{mod, Iterator, FromIterator, Extend};
use kinds::Sized;
use mem::{mod, replace};
use num;
Expand Down Expand Up @@ -1449,7 +1449,7 @@ impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for Has
}
}

impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Extendable<(K, V)> for HashMap<K, V, H> {
impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Extend<(K, V)> for HashMap<K, V, H> {
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
for (k, v) in iter {
self.insert(k, v);
Expand Down
4 changes: 2 additions & 2 deletions src/libstd/collections/hash/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use default::Default;
use fmt::Show;
use fmt;
use hash::{Hash, Hasher, RandomSipHasher};
use iter::{Iterator, FromIterator, FilterMap, Chain, Repeat, Zip, Extendable};
use iter::{Iterator, FromIterator, FilterMap, Chain, Repeat, Zip, Extend};
use iter;
use option::{Some, None};
use result::{Ok, Err};
Expand Down Expand Up @@ -574,7 +574,7 @@ impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T,
}
}

impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extendable<T> for HashSet<T, H> {
impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Extend<T> for HashSet<T, H> {
fn extend<I: Iterator<T>>(&mut self, mut iter: I) {
for k in iter {
self.insert(k);
Expand Down
11 changes: 10 additions & 1 deletion src/libstd/collections/lru_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ use cmp::{PartialEq, Eq};
use collections::HashMap;
use fmt;
use hash::Hash;
use iter::{range, Iterator};
use iter::{range, Iterator, Extend};
use mem;
use ops::Drop;
use option::{Some, None, Option};
Expand Down Expand Up @@ -329,6 +329,15 @@ impl<K: Hash + Eq, V> LruCache<K, V> {
/// Clear the cache of all key-value pairs.
#[unstable = "matches collection reform specification, waiting for dust to settle"]
pub fn clear(&mut self) { self.map.clear(); }

}

impl<K: Hash + Eq, V> Extend<(K, V)> for LruCache<K, V> {
fn extend<T: Iterator<(K, V)>>(&mut self, mut iter: T) {
for (k, v) in iter{
self.insert(k, v);
}
}
}

impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/io/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ use io::{IoResult, IoError, FileStat, SeekStyle, Seek, Writer, Reader};
use io::{Read, Truncate, SeekCur, SeekSet, ReadWrite, SeekEnd, Append};
use io::UpdateIoError;
use io;
use iter::{Iterator, Extendable};
use iter::{Iterator, Extend};
use kinds::Send;
use libc;
use option::{Some, None, Option};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/path/posix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use from_str::FromStr;
use hash;
use io::Writer;
use iter::{DoubleEndedIterator, AdditiveIterator, Extendable, Iterator, Map};
use iter::{DoubleEndedIterator, AdditiveIterator, Extend, Iterator, Map};
use option::{Option, None, Some};
use str::Str;
use str;
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/path/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
use from_str::FromStr;
use hash;
use io::Writer;
use iter::{AdditiveIterator, DoubleEndedIterator, Extendable, Iterator, Map};
use iter::{AdditiveIterator, DoubleEndedIterator, Extend, Iterator, Map};
use mem;
use option::{Option, Some, None};
use slice::{AsSlice, SlicePrelude};
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/prelude.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
#[doc(no_inline)] pub use clone::Clone;
#[doc(no_inline)] pub use cmp::{PartialEq, PartialOrd, Eq, Ord};
#[doc(no_inline)] pub use cmp::{Ordering, Less, Equal, Greater, Equiv};
#[doc(no_inline)] pub use iter::{FromIterator, Extendable, ExactSize};
#[doc(no_inline)] pub use iter::{FromIterator, Extend, ExactSize};
#[doc(no_inline)] pub use iter::{Iterator, DoubleEndedIterator};
#[doc(no_inline)] pub use iter::{RandomAccessIterator, CloneableIterator};
#[doc(no_inline)] pub use iter::{OrdIterator, MutableDoubleEndedIterator};
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/util/small_vector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<T> FromIterator<T> for SmallVector<T> {
}
}

impl<T> Extendable<T> for SmallVector<T> {
impl<T> Extend<T> for SmallVector<T> {
fn extend<I: Iterator<T>>(&mut self, mut iter: I) {
for val in iter {
self.push(val);
Expand Down