about summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorHideki Sekine <sekineh@me.com>2019-10-25 19:55:58 +0900
committerHideki Sekine <sekineh@me.com>2019-10-25 19:55:58 +0900
commit95442ae251d24c062ca317dcafdf3240f3cec846 (patch)
tree984220a26f852ae6aed60d546596ddcbde9c5d24 /src/liballoc
parent30e8f65549ec1a5ad401fec02b5cc9f9c974d871 (diff)
downloadrust-95442ae251d24c062ca317dcafdf3240f3cec846.tar.gz
rust-95442ae251d24c062ca317dcafdf3240f3cec846.zip
fix doctest
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/collections/binary_heap.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/liballoc/collections/binary_heap.rs b/src/liballoc/collections/binary_heap.rs
index 263a05df812..fda6f090fd7 100644
--- a/src/liballoc/collections/binary_heap.rs
+++ b/src/liballoc/collections/binary_heap.rs
@@ -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
     ///
@@ -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]