April 2026
Intermediate
631 pages
16h 20m
English
In this section, we’ll provide some practice questions to help reinforce your learning. The exercise questions cover almost all the concepts introduced in the chapter. Solutions to each exercise will follow in Section 13.7.
Fixing the size calculation of unsized typesThe following code snippet attempts to print the size of a raw array slice, which results in a compile-time error. Fix the issue and provide the correct way to handle the size of unsized types.
use std::mem::size_of;fn main() { println!("[i32] size is: {}", size_of::<[i32]>()); // Error: Size cannot be known at compile time}
Implementing correct handling of ?Sized trait bound in functionsFix the function some_fn so that it can correctly handle unsized ...
Read now
Unlock full access