Complete the code to create a min heap from the given vector.
let mut heap = std::collections::BinaryHeap::[1](vec);The from function creates a heap from an existing vector.
Complete the code to pop the smallest element from the min heap.
let smallest = heap.[1]().unwrap();The pop method removes and returns the smallest element in a min heap.
Fix the error in the code to create a min heap by reversing the order.
let mut heap = std::collections::BinaryHeap::from(vec.into_iter().map(|x| std::cmp::Reverse([1])).collect());
We wrap each element x with Reverse(x) to make a min heap.
Fill both blanks to complete the loop that pops k-1 smallest elements.
for _ in 0..[1] { heap.[2](); }
We pop k - 1 times to remove the smallest elements before the kth.
Use pop() to remove elements.
Fill all three blanks to return the kth smallest element from the min heap.
let kth_smallest = heap.[1]().map(|std::cmp::Reverse([2])| [3]).unwrap();
Pop the top element, unwrap the Reverse wrapper, and get the value.
