Converting collections using From/Into

could the standard library feature From implementations for various collections such as

impl<T: Hash + Clone> From<HashSet<T>> for Vec<T> {
    fn from(set: HashSet<T>) -> Self {

in the future?

Is this a good idea?
Currently we can not implement this generic impl ourselves, because of

[rustc E0117] [E] only traits defined in the current crate can be implemented for arbitrary types

impl doesn't use only types from inside the current crate

note: define and implement a trait or new type instead

FWIW, you don't need Clone -- set.into_iter().collect()

You can even just Vec::from_iter(set), although FromIterator isn't in the prelude.


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.