1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
use extend::ext; #[ext] impl i32 { fn add_one(&self) -> Self { self + 1 } fn foo() -> MyType { MyType } } #[derive(Debug, Eq, PartialEq)] struct MyType; fn main() { assert_eq!(i32::foo(), MyType); assert_eq!(1.add_one(), 2); }