<分区>
如果我有两个 String
,如何使用稳定的 Rust 将一个附加到另一个?这是一个简单的问题,但 stackoverflow 显然认为我不够冗长。这是一些额外的文本。
<分区>
如果我有两个 String
,如何使用稳定的 Rust 将一个附加到另一个?这是一个简单的问题,但 stackoverflow 显然认为我不够冗长。这是一些额外的文本。
最佳答案
来自 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 - 如何将一个字符串附加到另一个字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31156768/