Complete the code to create a Box pointer holding the value 5.
let b = [1]::new(5);
The Box::new function creates a Box pointer that owns the value on the heap.
Complete the code to dereference the Box pointer and print its value.
let b = Box::new(10); println!("{}", *[1]);
Dereferencing the Box pointer b with *b accesses the value inside.
Fix the error in the code by completing the blank to create a Box pointer to a string.
let s = [1]::new(String::from("hello"));
Box::new correctly creates a Box pointer owning the String on the heap.
Fill both blanks to create a Box pointer to an integer and then dereference it to get the value.
let b = [1]::new(42); let val = *[2];
First, Box::new creates the Box pointer. Then, dereferencing b with *b gets the value.
Fill all three blanks to create a Box pointer to a vector, push a value, and print the length.
let mut v = [1]::new(vec![1, 2, 3]); v.[2](4); println!("Length: {}", v.[3]());
Box::new creates the pointer to the vector. Then push adds an element, and len gets the vector length.