doc(string-clice.md): 调整字符串追加操作的示例代码,更具有语义

pull/1130/head
Robin Gong 2 years ago committed by GitHub
parent 0491ea1244
commit f225be6ba5
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