string - 如何将一个字符串附加到另一个字符串?

标签 string concatenation rust

<分区>

如果我有两个 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/

相关文章:

java - 将一行文本转换为 int 值

ruby - 尝试在 Array 子类中重新定义 += 似乎没有任何作用?

struct - 实现 Rust 特征会导致找不到结构

string - Haskell字符串到使用单词的字符串列表

java - 字符串作为 switch 语句

Lua:有没有办法连接 "nil"值?

rust - 为什么可以在不使用分号的情况下定义Rust结构?

rust - 无法在Windows Rust上建立bevy

python - Python使用通配符查找复杂子字符串

concatenation - jekyll 在循环中分配 concat?