std-method
BinaryHeap::new
Create an empty heap for later priority-based insertion. The type can be inferred from subsequent pushes. Expected stdout (not executed): true Some(8) Common mistake: Expecting a placeholder element in a new heap.
Formal Syntax & Structure
rust syntaxrust
fn new() -> BinaryHeap<T>Working Example
Example Snippetrust
fn main() { use std::collections::BinaryHeap; let mut jobs = BinaryHeap::new(); println!("{}", jobs.is_empty()); jobs.push(8); println!("{:?}", jobs.peek());}