nanvm_lib/common/array.rs
1use super::cast::Cast;
2
3impl<T, const N: usize> Cast<Vec<T>> for [T; N] {
4 /// Move the array into a vector.
5 /// Compare to `.to_vec()`, the function doesn't require `Clone` trait.
6 fn cast(self) -> Vec<T> {
7 let mut result = Vec::with_capacity(N);
8 for i in self {
9 result.push(i);
10 }
11 result
12 }
13}