AsRef

🤔 refer to Airat Galiullin

// This 👇 did the trick.
fn hello<T: AsRef<str>>(planet: T) {
    println!("Hello, {}!", planet.as_ref());
}

fn main() {
    // String
    hello("Earth".to_string());

    // &str
    hello("Mars");
}