mirror of
https://github.com/sunface/rust-by-practice.git
synced 2025-06-23 04:29:41 +00:00
修正切片练习题2错误
This commit is contained in:
@ -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!");
|
||||
}
|
||||
|
Reference in New Issue
Block a user