parent
16c8cd931c
commit
a11f16739f
2 changed files with 26 additions and 1 deletions
|
@ -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)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
use std::prelude::*;
|
use std::prelude::*;
|
||||||
|
|
|
@ -41,7 +41,7 @@ use cmp::{PartialEq, Eq};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use fmt;
|
use fmt;
|
||||||
use hash::Hash;
|
use hash::Hash;
|
||||||
use iter::{range, Iterator};
|
use iter::{range, Iterator, Extend};
|
||||||
use mem;
|
use mem;
|
||||||
use ops::Drop;
|
use ops::Drop;
|
||||||
use option::{Some, None, Option};
|
use option::{Some, None, Option};
|
||||||
|
@ -329,6 +329,15 @@ impl<K: Hash + Eq, V> LruCache<K, V> {
|
||||||
/// Clear the cache of all key-value pairs.
|
/// Clear the cache of all key-value pairs.
|
||||||
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
#[unstable = "matches collection reform specification, waiting for dust to settle"]
|
||||||
pub fn clear(&mut self) { self.map.clear(); }
|
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> {
|
impl<A: fmt::Show + Hash + Eq, B: fmt::Show> fmt::Show for LruCache<A, B> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue