Complete the code to create a new empty deque.
let mut deque = std::collections::VecDeque::[1]();with_capacity requires a size argument.from needs an existing collection.default is valid but less explicit here.The new() function creates an empty deque.
Complete the code to add an element to the front of the deque.
deque.[1](10);
push_back adds to the back, not front.insert requires an index argument.append is for concatenating collections.push_front() adds an element to the front of the deque.
Fix the error in the code to remove an element from the back of the deque.
let last = deque.[1]().unwrap();pop_front removes from the front.remove requires an index argument.take is not a method on VecDeque.pop_back() removes and returns the last element from the deque.
Fill both blanks to check if the deque is empty and print a message.
if deque.[1]() [2] { println!("Deque is empty"); }
is_full() which does not exist for VecDeque.!= false is correct but less clear here.is_empty() returns true if the deque has no elements. Comparing with == true confirms this condition.
Fill all three blanks to create a deque from a vector, add an element at the back, and remove from the front.
let mut deque = std::collections::VecDeque::[1](vec![1, 2, 3]); deque.[2](4); let first = deque.[3]().unwrap();
new() instead of from() to create from vector.push_front() instead of push_back().pop_back() instead of pop_front().from() creates a deque from a vector. push_back() adds an element at the end. pop_front() removes the first element.
