How to Define and Implement a Trait in Rust

Define a trait using the `trait` keyword and implement it for a type using `impl TraitName for Type` to share behavior across different structs.

Define a trait with the trait keyword to declare shared behavior, then use impl TraitName for Type to provide the concrete logic for a specific type.

trait Message {
    fn call(&self);
}

struct MyMessage;

impl Message for MyMessage {
    fn call(&self) {
        println!("Message sent");
    }
}

fn main() {
    let m = MyMessage;
    m.call();
}