Skip to content

Commit

Permalink
fix doctest
Browse files Browse the repository at this point in the history
  • Loading branch information
sekineh committed Oct 25, 2019
1 parent 30e8f65 commit 95442ae
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/liballoc/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,11 +650,12 @@ impl<T: Ord> BinaryHeap<T> {
}

/// Returns an iterator which retrieves elements in heap order.
/// The retrieved elements will be removed from the original heap.
/// The remaining elements are removed on drop in heap order.
/// The retrieved elements are removed from the original heap.
/// The remaining elements will be removed on drop in heap order.
///
/// Note:
/// * `.drain_sorted()` is O(n lg n); much slower than `.drain()`.
/// You should use the latter for most cases.
///
/// # Examples
///
Expand All @@ -667,14 +668,7 @@ impl<T: Ord> BinaryHeap<T> {
/// let mut heap = BinaryHeap::from(vec![1, 2, 3, 4, 5]);
/// assert_eq!(heap.len(), 5);
///
/// let removed = heap.drain_sorted()
/// .take(3).collect::<Vec<_>>(); // removes 3 elements in heap order
///
/// assert_eq!(removed, vec![5, 4, 3]);
/// assert_eq!(heap.len(), 2);
///
/// drop(drain_sorted); // removes remaining elements in heap order
///
/// drop(heap.drain_sorted()); // removes all elements in heap order
/// assert_eq!(heap.len(), 0);
/// ```
#[inline]
Expand Down

0 comments on commit 95442ae

Please sign in to comment.