Rust Search

Find the best content on Rust, curated by the community; a search engine for Rustaceans.
doc.rust-lang.org
pub struct BinaryHeap<T, A>
A priority queue implemented with a binary heap.
struct alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn append(&mut self, other: &mut Self)
Moves all the elements of other into self, leaving other empty.
method alloc Stable since 1.11.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn as_slice(&self) -> &[T]
Returns a slice of all values in the underlying vector, in arbitrary order.
method alloc Stable since 1.80.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn capacity(&self) -> usize
Returns the number of elements the binary heap can hold without reallocating.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn clear(&mut self)
Drops all items from the binary heap.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn drain(&mut self) -> Drain<'_, T, A>
Clears the binary heap, returning an iterator over the removed elements in arbitrary order. If the iterator is dropped before being fully consumed, it drops the remaining elements in arbitrary order.
method alloc Stable since 1.6.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_sorted_vec(self) -> Vec<T, A>
Consumes the BinaryHeap and returns a vector in sorted (ascending) order.
method alloc Stable since 1.5.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn into_vec(self) -> Vec<T, A>
Consumes the BinaryHeap and returns the underlying vector in arbitrary order.
method alloc Stable since 1.5.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn is_empty(&self) -> bool
Checks if the binary heap is empty.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn iter(&self) -> Iter<'_, T>
Returns an iterator visiting all values in the underlying vector, in arbitrary order.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn len(&self) -> usize
Returns the length of the binary heap.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub const fn new() -> BinaryHeap<T>
Creates an empty BinaryHeap as a max-heap.
associated_function alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn peek(&self) -> Option<&T>
Returns the greatest item in the binary heap, or None if it is empty.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn peek_mut(&mut self) -> Option<PeekMut<'_, T, A>>
Returns a mutable reference to the greatest item in the binary heap, or None if it is empty.
method alloc Stable since 1.12.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn pop(&mut self) -> Option<T>
Removes the greatest item from the binary heap and returns it, or None if it is empty.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn push(&mut self, item: T)
Pushes an item onto the binary heap.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve(&mut self, additional: usize)
Reserves capacity for at least additional elements more than the current length. The allocator may reserve more space to speculatively avoid frequent allocations. After calling reserve, capacity will be greater than or equal to self.len() + additional. Does nothing if capacity is already sufficient.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn reserve_exact(&mut self, additional: usize)
Reserves the minimum capacity for at least additional elements more than the current length. Unlike reserve, this will not deliberately over-allocate to speculatively avoid frequent allocations. After calling reserve_exact, capacity will be greater than or equal to self.len() + additional. Does nothing if the capacity is already sufficient.
method alloc Stable since 1.0.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn retain<F>(&mut self, f: F)
Retains only the elements specified by the predicate.
method alloc Stable since 1.70.0 Version 1.100.0-nightly
doc.rust-lang.org
pub fn shrink_to(&mut self, min_capacity: usize)
Discards capacity with a lower bound.
method alloc Stable since 1.56.0 Version 1.100.0-nightly
"Rust is one of those friends that take some time to get along with, but that you'll finally want to engage with for a long term relationship."

Search tips

Type anything to search across articles, videos (including conference talks), podcasts, research, crates, and Rust API documentation. These operators give you finer control — click an example to try it.

Find pages containing all your words. Pages where the words appear together rank higher.
Quote part of your query to keep those words together as an exact phrase within a larger search.
Wrap the whole query in quotes for a verbatim search that matches text exactly, punctuation and all — perfect for Rust syntax. Needs at least 3 characters.
Put ! first to open the top result immediately. Quote the whole query for a literal leading bang, as in '!Send'. Bangs elsewhere, such as println!, stay literal. Browser and launcher shortcuts can invoke this directly. See search integrations.
Limit results to a single site. Works on its own () too. One site: per search.

Use the tabs and filters above the results to narrow by content type, publication year, and sort order.