AsRef
// 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"); }
// 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"); }