From 9f366fc5e3c0121af1534fd927e3f63bdfc9987b Mon Sep 17 00:00:00 2001 From: tomoat Date: Fri, 18 Feb 2022 16:01:16 +0800 Subject: [PATCH] Update string-slice.md --- contents/basic/compound-type/string-slice.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contents/basic/compound-type/string-slice.md b/contents/basic/compound-type/string-slice.md index 60b25976..698feaf6 100644 --- a/contents/basic/compound-type/string-slice.md +++ b/contents/basic/compound-type/string-slice.md @@ -83,7 +83,7 @@ let slice = &s[..]; >在对字符串使用切片语法时需要格外小心,切片的索引必须落在字符之间的边界位置,也就是UTF8字符的边界,例如中文在UTF8中占用三个字节,下面的代码就会崩溃: >```rust -> let s = String::from("中国人"); +> let s = "中国人"; > let a = &s[0..2]; > println!("{}",a); >```