use core::convert::TryInto; use edyn::edyn; #[edyn] trait IsAttribute { fn size(&self) -> usize; } impl IsAttribute for Vec { fn size(&self) -> usize { self.len() * std::mem::size_of::() } } impl IsAttribute for Vec { fn size(&self) -> usize { self.len() * std::mem::size_of::() } } #[edyn(IsAttribute)] enum AnyAttribute { VariantVector2Forf32(Vec), VariantVector3Forf32(Vec), } #[test] fn main() { let floats: Vec = vec![0., 1., 2., 3.]; let doubles: Vec = vec![0., 1., 2., 3., 4., 5., 6., 7.]; let mut all: Vec = vec![floats.into(), doubles.into()]; assert_eq!(all[0].size(), 16); assert_eq!(all[1].size(), 64); let doubles: Vec = all.pop().unwrap().try_into().unwrap(); let floats: Vec = all.pop().unwrap().try_into().unwrap(); assert_eq!(floats, vec![0.0f32, 1., 2., 3.]); assert_eq!(doubles, vec![0.0f64, 1., 2., 3., 4., 5., 6., 7.]); }