A blanket implementation implements a trait for every type satisfying specified bounds. It can remove duplication, but broad behavior may make code harder to understand than an ordinary function or generic function. section 1.3.2
Listing 1.2 The powers and dangers of generics
trait Hello {
fn hello(&self);
}
impl<T:Copy> Hello for T {
fn hello(&self) {
println!("Hello world");
}
}
fn main() {
2.hello();
true.hello();
'c'.hello();
}
An extension trait named Hello is implemented for every Copy type, making hello available on numbers, characters, and Booleans. section 1.3.2
Use blanket implementations carefully:
- Prefer them when the added behavior is clear and well-defined. section 1.3.2
- Treat them as an alternative to generic functions for avoiding duplication, not as an automatic default. section 1.3.2
- Avoid broad implementations when readers must inspect the implementation to understand ordinary code. section 1.3.2


