如何将一个字符串附加到另一个字符串?
How to append a String to another String?
如果我有两个 String
,如何使用稳定的 Rust 将一个附加到另一个?这是一个简单的问题,但 Whosebug 显然认为我不够冗长。这是一些额外的文字。
来自here
If you have a String, you can concatenate a &str to the end of it:
let hello = "Hello ".to_string(); let world = "world!";
let hello_world = hello + world;
But if you have two Strings, you need an &:
let hello = "Hello ".to_string();
let world = "world!".to_string();
let hello_world = hello + &world;
如果我有两个 String
,如何使用稳定的 Rust 将一个附加到另一个?这是一个简单的问题,但 Whosebug 显然认为我不够冗长。这是一些额外的文字。
来自here
If you have a String, you can concatenate a &str to the end of it:
let hello = "Hello ".to_string(); let world = "world!";
let hello_world = hello + world;
But if you have two Strings, you need an &:
let hello = "Hello ".to_string();
let world = "world!".to_string();
let hello_world = hello + &world;