Better Trait Resolution in Rust

from blog mcyoung, | ↗ original
↗ original
Traits are the core of polymorphism in Rust. Let’s review: trait Stringer { fn string(&self) -> String; } impl Stringer for i32 { fn string(&self) -> String { format!("{self}") } } // Prints `42`. println!("{}", 42.string());godboltRust Notice that we call the trait method Stringer::string directly on the value in question. This means that traits...