5. You have a doubly linked list with nodes: 5 <-> 15 <-> 25 <-> 35. After deleting the first node twice using correct Rust code, what will be the final list printed?
let mut head = Some(Box::new(Node { val: 5, prev: None, next: Some(Box::new(Node { val: 15, prev: None, next: Some(Box::new(Node { val: 25, prev: None, next: Some(Box::new(Node { val: 35, prev: None, next: None })) })) })) }));
// Delete first node twice
for _ in 0..2 {
if let Some(mut node) = head.take() {
head = node.next.take();
if let Some(ref mut new_head) = head {
new_head.prev = None;
}
}
}
// Print list
let mut current = &head;
while let Some(node) = current {
print!("{} -> ", node.val);
current = &node.next;
}
print!("null");