std-method
BinaryHeap::append
Move every element from another heap into this one, preserving priority behavior and leaving the other empty. Duplicates remain distinct entries. Expected stdout (not executed): 4 true Some(9) Common mistake: Expecting set-style duplicate elimination.
Formal Syntax & Structure
rust syntaxrust
fn append(&mut self, other: &mut Self)Working Example
Example Snippetrust
fn main() { use std::collections::BinaryHeap; let mut urgent = BinaryHeap::from([9, 2]); let mut later = BinaryHeap::from([4, 9]); urgent.append(&mut later); println!("{} {}", urgent.len(), later.is_empty()); println!("{:?}", urgent.pop());}