Exploring Strings in Rust

deref coercions

https://rustwiki.org/zh-CN/book/ch15-02-deref.html#函数和方法的隐式解引用强制转换

String&str

fn hello(name: &str) {
    println!("Hello, {}!", name);
}

fn main() {
    let m = Box::new(String::from("Rust")); // type: Box<String>
    hello(&m); // &Box<String> -> &String -> &str
}