use edyn::edyn; pub struct SuperFoo { _bar: T, } impl Foo for SuperFoo { fn do_something(&mut self, _val: T) { println!("SuperFoo"); } } pub struct UltraFoo { _bar: T, } impl Foo for UltraFoo { fn do_something(&mut self, _val: T) { println!("UltraFoo"); } } pub trait Bar {} #[edyn] pub trait Foo { fn do_something(&mut self, val: T); } #[edyn(Foo)] pub enum AnyFoo { SuperFoo(SuperFoo), UltraFoo(UltraFoo), } #[edyn] pub trait Faz {} use std::marker::PhantomData; pub struct SuperFaz<'a>(PhantomData<&'a u8>); pub struct UltraFaz(); impl<'a> Faz for SuperFaz<'a> {} impl Faz for UltraFaz {} #[edyn(Faz)] pub enum AnyFaz<'a> { SuperFaz(SuperFaz<'a>), UltraFaz(UltraFaz), } #[test] fn main() { use core::convert::TryInto; let anyfaz: AnyFaz = SuperFaz(PhantomData::<&u8>::default()).into(); let superfaz: Result = anyfaz.try_into(); assert!(superfaz.is_ok()); }