Skip to content

Commit 95442ae

Browse files
committed
fix doctest
1 parent 30e8f65 commit 95442ae

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

src/liballoc/collections/binary_heap.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -650,11 +650,12 @@ impl<T: Ord> BinaryHeap<T> {
650650
}
651651

652652
/// Returns an iterator which retrieves elements in heap order.
653-
/// The retrieved elements will be removed from the original heap.
654-
/// The remaining elements are removed on drop in heap order.
653+
/// The retrieved elements are removed from the original heap.
654+
/// The remaining elements will be removed on drop in heap order.
655655
///
656656
/// Note:
657657
/// * `.drain_sorted()` is O(n lg n); much slower than `.drain()`.
658+
/// You should use the latter for most cases.
658659
///
659660
/// # Examples
660661
///
@@ -667,14 +668,7 @@ impl<T: Ord> BinaryHeap<T> {
667668
/// let mut heap = BinaryHeap::from(vec![1, 2, 3, 4, 5]);
668669
/// assert_eq!(heap.len(), 5);
669670
///
670-
/// let removed = heap.drain_sorted()
671-
/// .take(3).collect::<Vec<_>>(); // removes 3 elements in heap order
672-
///
673-
/// assert_eq!(removed, vec![5, 4, 3]);
674-
/// assert_eq!(heap.len(), 2);
675-
///
676-
/// drop(drain_sorted); // removes remaining elements in heap order
677-
///
671+
/// drop(heap.drain_sorted()); // removes all elements in heap order
678672
/// assert_eq!(heap.len(), 0);
679673
/// ```
680674
#[inline]

0 commit comments

Comments
 (0)