Rust doesn't have inheritance. The SpeakWell: Speak syntax means "if you implement SpeakWell, you also have to implement Speak", but the traits remain separate and unrelated. There is no automatic subclassing in dyn.
You will have to add as_speak(&self) -> &dyn Speak to SpeakWell and implement the cast.
I suggest "flattening" hierarchies for Rust. Traditional OOP architecture won't fit it well.
Another option is to use &'_ (impl Speak + ?Sized) (i.e., accept anything that implements Speak, including all the trait objects (?Sized) that so do), instead of &'_ (dyn Speak) (i.e., accept exactly the "parent" trait object dyn Speak):
pub
trait Speak {
fn speak (self: &'_ Self)
;
}
pub
trait SpeakWell : Speak {
fn speak_well (self: &'_ Self)
;
}
////// implementors
struct P {}
impl SpeakWell for P {
fn speak_well (self: &'_ Self)
{
println!("The senate will decide your fate.")
}
}
impl Speak for P {
fn speak (self: &'_ Self)
{
println!("*I* am the senate!")
}
}
pub
fn dinner (speaker: &'_ (impl SpeakWell + ?Sized))
{
speaker.speak_well();
}
pub
fn conference (speaker: &'_ (impl Speak + ?Sized))
{
speaker.speak();
}