1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
use extend::ext; trait MyTrait {} impl MyTrait for String {} #[ext(supertraits = Default + Clone + MyTrait)] impl String { fn my_len(&self) -> usize { self.len() } } fn main() { assert_eq!(String::new().my_len(), 0); }