Complete the code to declare a fixed-size array of 5 integers in Rust.
let numbers: [i32; [1]] = [1, 2, 3, 4, 5];
The array size must match the number of elements. Here, 5 elements require size 5.
Complete the code to create a linked list node struct with a value and a next pointer.
struct Node {
value: i32,
next: Option<Box<[1]>>,
}The next pointer must point to the same Node type wrapped in Box and Option for linked list.
Fix the error in the code to correctly create a linked list node with value 10 and no next node.
let node = Node {
value: 10,
next: [1],
};The next field is an Option
Fill both blanks to create a vector and access its first element safely.
let numbers = Vec::new(); numbers.push(1); let first = numbers.[1]().[2]();
Use first() to get an Option reference to the first element, then unwrap() to get the value.
Fill all three blanks to create a linked list node with value 5 and next node with value 10.
let second = Node {
value: [1],
next: None,
};
let first = Node {
value: [2],
next: Some(Box::new([3])),
};The second node has value 10 and no next. The first node has value 5 and points to second.
