1pub trait IntoFlattened<T> {
6 fn into_flattened(self) -> Vec<T>;
7}
8
9impl<T> IntoFlattened<T> for Vec<Vec<T>> {
10 fn into_flattened(self) -> Vec<T> {
11 let mut output = Vec::new();
12 for mut vec in self {
13 output.append(&mut vec);
14 }
15 output
16 }
17}
18
19pub trait Flattened<T: ToOwned<Owned = U>, U> {
20 fn flattened(self) -> Vec<U>;
21}
22
23impl<T: ToOwned<Owned = U>, U, V: AsRef<[T]>> Flattened<T, U> for &[V] {
24 fn flattened(self) -> Vec<U> {
25 let mut output: Vec<U> = Vec::new();
26 for v in self {
27 for item in v.as_ref() {
28 output.push(item.to_owned());
29 }
30 }
31 output
32 }
33}