From f225be6ba5ec56ff0c4be92b16c29a12157f2b95 Mon Sep 17 00:00:00 2001 From: Robin Gong Date: Wed, 18 Jan 2023 16:40:36 +0800 Subject: [PATCH] =?UTF-8?q?doc(string-clice.md):=20=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E5=AD=97=E7=AC=A6=E4=B8=B2=E8=BF=BD=E5=8A=A0=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E7=9A=84=E7=A4=BA=E4=BE=8B=E4=BB=A3=E7=A0=81=EF=BC=8C=E6=9B=B4?= =?UTF-8?q?=E5=85=B7=E6=9C=89=E8=AF=AD=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/basic/compound-type/string-slice.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/basic/compound-type/string-slice.md b/src/basic/compound-type/string-slice.md index 98dd1cc2..e4fd7382 100644 --- a/src/basic/compound-type/string-slice.md +++ b/src/basic/compound-type/string-slice.md @@ -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)