use crate::{
extensions::FromPatch, misc::EasyUnwrapUnchecked, prelude::IntoPatch,
};
impl<T: IntoPatch<S>, S, const N: usize> FromPatch<[T; N]> for Vec<S> {
fn from_value(v: [T; N]) -> Self {
let mut o = Self::with_capacity(N);
for i in v {
o.push(i.into_value());
}
o
}
}
impl<T: Clone + IntoPatch<S>, S> FromPatch<&[T]> for Vec<S> {
fn from_value(v: &[T]) -> Self {
v.iter().map(|x| x.clone().into_value()).collect()
}
}
impl<T: IntoPatch<S>, S> FromPatch<Vec<T>> for Vec<S> {
fn from_value(v: Vec<T>) -> Self {
let mut o = Self::with_capacity(v.len());
for i in v {
o.push(i.into_value());
}
o
}
}
impl<T: Clone + IntoPatch<S>, S, const N: usize> FromPatch<[T; N]> for [S; N] {
fn from_value(v: [T; N]) -> Self {
let vec: Vec<S> = v.into_iter().map(IntoPatch::into_value).collect();
vec.try_into().easy_unwrap_unchecked()
}
}