Skip to main content

SingleSpeaker

Trait SingleSpeaker 

Source
pub(crate) trait SingleSpeaker {
    // Required method
    fn speak(&self);
}
Expand description

Part 4: Monomorphic dispatch via a generic function.

The compiler monomorphizes direct_speak for each concrete type it is called with, so the call to speak is resolved statically at compile time (no vtable, no indirection) - analogous to Java calling a method on a final class through a concrete reference.

Required Methods§

Source

fn speak(&self)

Emits the sound associated with this single, non-polymorphic speaker.

Implementors§