use crate::any::ConfigData; use crate::validator::Ty; use crate::Value; pub trait IntoTy: Clone { type Ty: Ty; fn into_ty(self) -> Self::Ty; } impl IntoTy for T { type Ty = Self; fn into_ty(self) -> Self::Ty { self } } impl IntoTy for &[T] { type Ty = Box<[T::Ty]>; fn into_ty(self) -> Self::Ty { self.iter().cloned().map(T::into_ty).collect() } } impl IntoTy for &[T; N] { type Ty = Box<[T::Ty]>; fn into_ty(self) -> Self::Ty { self.iter().cloned().map(T::into_ty).collect() } } impl IntoTy for &str { type Ty = Box; fn into_ty(self) -> Self::Ty { self.into() } } pub(super) fn ty_into_value(val: &ConfigData) -> Value { T::to_value(val.get()) }