这有效:
let hello = "Hello ".to_string();
let world = "world!";
let hello_world = hello + world;
但是这个不会:let hello = "Hello ".to_string();
let world = "world!".to_string();
let hello_world = hello + world;
但是这个确实会:
let hello = "Hello ".to_string();
let world = "world!".to_string();
let hello_world = hello + &world;
是否因为String
需要指向第二个String
的原始字符串切片的指针?如果是这样,为什么呢?