#![feature(async_fn_in_trait)] use edyn::edyn; struct A; struct B; impl XTrait for A { async fn run(&mut self) -> Result { Ok(10) } } impl XTrait for B { async fn run(&mut self) -> Result { Ok(20) } } #[edyn] enum X { A, B, } #[edyn(X)] trait XTrait { async fn run(&mut self) -> Result; } fn main() -> smol::io::Result<()> { let mut a: X = A.into(); let mut b: X = B.into(); smol::block_on(async { assert_eq!(10, a.run().await.unwrap()); assert_eq!(20, b.run().await.unwrap()); Ok(()) }) }