From 81d8752422d8a7d36626f8821b5bad53f31b5b99 Mon Sep 17 00:00:00 2001 From: me Date: Mon, 18 Jul 2022 16:37:01 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=88=87=E7=89=87?= =?UTF-8?q?=E7=BB=83=E4=B9=A0=E9=A2=982=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- en/src/compound-types/slice.md | 6 +++--- zh-CN/src/compound-types/slice.md | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/en/src/compound-types/slice.md b/en/src/compound-types/slice.md index b9d149d..5fe1e65 100644 --- a/en/src/compound-types/slice.md +++ b/en/src/compound-types/slice.md @@ -25,9 +25,9 @@ fn main() { let slice = &arr[..2]; - // Modify '6' to make it work - // TIPS: slice( reference ) IS NOT an array, if it is an array, then `assert!` will passed: Each of the two UTF-8 chars '中' and '国' occupies 3 bytes, 2 * 3 = 6 - assert!(std::mem::size_of_val(&slice) == 6); + // Modify '8' to make it work + // TIPS: slice( reference ) IS NOT an array, if it is an array, then `assert!` will passed: Each of the two chars '中' and '国' occupies 4 bytes, 2 * 4 = 8 + assert!(std::mem::size_of_val(&slice) == 8); println!("Success!"); } diff --git a/zh-CN/src/compound-types/slice.md b/zh-CN/src/compound-types/slice.md index 4cb9956..b6baa47 100644 --- a/zh-CN/src/compound-types/slice.md +++ b/zh-CN/src/compound-types/slice.md @@ -25,9 +25,9 @@ fn main() { let slice = &arr[..2]; - // 修改数字 `6` 让代码工作 - // 小提示: 切片和数组不一样,它是引用。如果是数组的话,那下面的 `assert!` 将会通过: 因为'中'和'国'是 UTF-8 字符,它们每个占用 3 个字节,2 个字符就是 6 个字节 - assert!(std::mem::size_of_val(&slice) == 6); + // 修改数字 `8` 让代码工作 + // 小提示: 切片和数组不一样,它是引用。如果是数组的话,那下面的 `assert!` 将会通过: '中'和'国'是char类型,char类型是Unicode编码,大小固定为4字节,两个字符为8字节。 + assert!(std::mem::size_of_val(&slice) == 8); } ``` From 58b21202bf76fa8a0fba1ecd996d35b7eec848f6 Mon Sep 17 00:00:00 2001 From: me Date: Tue, 19 Jul 2022 22:58:53 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BF=AE=E6=AD=A38.1=E4=B9=A0=E9=A2=98?= =?UTF-8?q?=E7=AD=94=E6=A1=88=E9=93=BE=E6=8E=A5=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- zh-CN/src/pattern-match/match-iflet.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zh-CN/src/pattern-match/match-iflet.md b/zh-CN/src/pattern-match/match-iflet.md index d37e931..757ca7c 100644 --- a/zh-CN/src/pattern-match/match-iflet.md +++ b/zh-CN/src/pattern-match/match-iflet.md @@ -194,4 +194,4 @@ fn main() { } ``` -> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/pattern-match/match-iflet.md)找到答案(在 solutions 路径下) \ No newline at end of file +> 你可以在[这里](https://github.com/sunface/rust-by-practice/blob/master/solutions/pattern-match/match.md)找到答案(在 solutions 路径下) \ No newline at end of file