For reference, the FromIterator & Extendable traits are the things to implement if one has a structure that can be constructed from/extended with an iterator and wishes to share the behaviour.


http://static.rust-lang.org/doc/master/std/iter/trait.FromIterator.html
http://static.rust-lang.org/doc/master/std/iter/trait.Extendable.html

Thanks for pointing that out :)
Implementing FromIterator should work out fine. Extendable would need a persistent version returning the newly created instance, something like:

mod persistent {
pub trait Extendable<A>: FromIterator <http://static.rust-lang.org/doc/master/std/iter/trait.FromIterator.html><A> { fn extend <http://static.rust-lang.org/doc/master/std/iter/trait.Extendable.html#tymethod.extend><T: Iterator <http://static.rust-lang.org/doc/master/std/iter/trait.Iterator.html><A>>(&self, iterator: &mut T) -> Self;
    }
}
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to