Files
2026-09-29 11:57:40 -07:00

16 lines
247 B
Rust

// simple example of extension trait
// how to add square method to i32
trait Square {
fn square(self) -> Self;
}
impl Square for i32 {
fn square(self) -> Self {
self * self
}
}
fn main() {
println!("{}", 32.square());
}