Here the Speak
trait has the blanket implementation for the references of any type that implement the Speak
trait (Human
type in the current example). That allows to pass Human
, &Human
, and &mut Human
to the introduce
method that expects a trait that has Speak
trait implemented. The blanket implementation is necessary as Rust doesn't dereference types in traits.
trait Speak {
fn speak(&self);
}
// Blanket implementation for &T