trait Greet { fn greet(&self) -> String; } struct EnglishGreeter; impl Greet for EnglishGreeter { fn greet(&self) -> String { // TODO: "Hello!".to_string() } } fn main() { let g = EnglishGreeter; println!("{}", g.greet()); }
Output
Click Run to execute, or Check to validate.
Ask questions or share tips about this tutorial
Sign in to join the discussion