extern crate ambassador; use ambassador::*; use std::collections::{BTreeMap, HashMap}; #[delegatable_trait] pub trait IntoMany { const N: usize; } impl IntoMany for u32 { const N: usize = 4; } impl IntoMany for u32 { const N: usize = 2; } impl IntoMany for u16 { const N: usize = 2; } impl IntoMany for char { const N: usize = 4; } #[derive(Delegate)] #[delegate(IntoMany, generics = "X")] pub enum CharOrU32 { Char(char), U32(u32), } fn main() { assert_eq!(>::N, 4); }