Trait redox::iter::FromIterator
[−]
[src]
pub trait FromIterator<A> {
fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=A>;
}
Conversion from an Iterator
.
Required Methods
fn from_iter<T>(iterator: T) -> Self where T: IntoIterator<Item=A>
Builds a container with elements from something iterable.
Examples
use std::collections::HashSet; use std::iter::FromIterator; let colors_vec = vec!["red", "red", "yellow", "blue"]; let colors_set = HashSet::<&str>::from_iter(colors_vec); assert_eq!(colors_set.len(), 3);
FromIterator
is more commonly used implicitly via the
Iterator::collect
method:
use std::collections::HashSet; let colors_vec = vec!["red", "red", "yellow", "blue"]; let colors_set = colors_vec.into_iter().collect::<HashSet<&str>>(); assert_eq!(colors_set.len(), 3);
Implementors
impl<A, V> FromIterator<Option<A>> for Option<V> where V: FromIterator<A>
impl<A, E, V> FromIterator<Result<A, E>> for Result<V, E> where V: FromIterator<A>
impl<T> FromIterator<T> for BinaryHeap<T> where T: Ord
impl<K, V> FromIterator<(K, V)> for BTreeMap<K, V> where K: Ord
impl<T> FromIterator<T> for BTreeSet<T> where T: Ord
impl<E> FromIterator<E> for EnumSet<E> where E: CLike
impl<A> FromIterator<A> for LinkedList<A>
impl FromIterator<char> for String
impl<'a> FromIterator<&'a str> for String
impl FromIterator<String> for String
impl<T> FromIterator<T> for Vec<T>
impl<'a, T> FromIterator<T> for Cow<'a, [T]> where T: Clone
impl<A> FromIterator<A> for VecDeque<A>