Exerpad
🔥0
0 XP
Lv.1 Beginner
Log In

Fix the Trait

This code defines a trait and tries to use it, but the implementation is missing! Add the impl block so it prints:

text
Hi, I'm Luna!

Hint: Add impl Greet for Person { ... } with the hello method.

rust
trait Greet {
fn hello(&self) -> String;
}

struct Person {
name: String,
}

fn main() {
let p = Person { name: String::from("Luna") };
println!("{}", p.hello());
}