Skip to content

Commit dd2b8a0

Browse files
committed
provide a more realistic example for BinaryHeap::as_slice
1 parent 6233f3f commit dd2b8a0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

library/alloc/src/collections/binary_heap.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -899,13 +899,11 @@ impl<T> BinaryHeap<T> {
899899
/// ```
900900
/// #![feature(binary_heap_as_slice)]
901901
/// use std::collections::BinaryHeap;
902+
/// use std::io::{self, Write};
903+
///
902904
/// let heap = BinaryHeap::from(vec![1, 2, 3, 4, 5, 6, 7]);
903-
/// let slice = heap.as_slice();
904905
///
905-
/// // Will print in some order
906-
/// for x in slice {
907-
/// println!("{}", x);
908-
/// }
906+
/// io::sink().write(heap.as_slice()).unwrap();
909907
/// ```
910908
#[unstable(feature = "binary_heap_as_slice", issue = "82331")]
911909
pub fn as_slice(&self) -> &[T] {

0 commit comments

Comments
 (0)