Merge pull request #1130 from RobinGG/patch-1

doc(string-clice.md): 调整字符串追加操作的示例代码,更具有语义
pull/1144/head
Sunface 2 years ago committed by GitHub
commit 6af76de344
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -289,19 +289,20 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
```rust
fn main() {
let mut s = String::from("Hello ");
s.push('r');
println!("追加字符 push() -> {}", s);
s.push_str("ust!");
s.push_str("rust");
println!("追加字符串 push_str() -> {}", s);
s.push('!');
println!("追加字符 push() -> {}", s);
}
```
代码运行结果:
```console
追加字符 push() -> Hello r
追加字符 push_str() -> Hello rust!
追加字符 push_str() -> Hello rust
追加字符 push() -> Hello rust!
```
#### 插入 (Insert)

Loading…
Cancel
Save