Merge pull request #405 from SaberA1ter/master

Update problem 2 TIPS in slice.md
This commit is contained in:
Sunface
2023-06-14 08:45:21 +08:00
committed by GitHub

View File

@ -17,7 +17,7 @@ fn main() {
let slice = &arr[..2]; let slice = &arr[..2];
// 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 // TIPS: slice( reference ) IS NOT an array, because if it is, then `assert!` will passed: each of the two UTF-8 chars '中' and '国' occupies 4 bytes, 2 * 4 = 8
assert!(std::mem::size_of_val(&slice) == 16); assert!(std::mem::size_of_val(&slice) == 16);
} }
``` ```