Merge pull request #248 from kscale/patch-1

Update string-slice.md
pull/249/head
Sunface 3 years ago committed by GitHub
commit e20f6dd757
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -81,7 +81,7 @@ let slice = &s[0..len];
let slice = &s[..];
```
>在对字符串使用切片语法时需要格外小心切片的索引必须落在字符之间的边界位置也就是UTF8字符的边界例如中文在UT8中占用三个字节,下面的代码就会崩溃:
>在对字符串使用切片语法时需要格外小心切片的索引必须落在字符之间的边界位置也就是UTF8字符的边界例如中文在UTF8中占用三个字节,下面的代码就会崩溃:
>```rust
> let s = "中国人";
> let a = &s[0..2];

Loading…
Cancel
Save