Skip to content

Commit

Permalink
Implement Debug for BinaryHeap
Browse files Browse the repository at this point in the history
Fixes #28154
  • Loading branch information
nagisa committed Sep 1, 2015
1 parent 05cc464 commit 8db906c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/libcollections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
use core::iter::{FromIterator};
use core::mem::swap;
use core::ptr;
use core::fmt;

use slice;
use vec::{self, Vec};
Expand All @@ -178,6 +179,13 @@ impl<T: Ord> Default for BinaryHeap<T> {
fn default() -> BinaryHeap<T> { BinaryHeap::new() }
}

#[stable(feature = "binaryheap_debug", since = "1.4.0")]
impl<T: fmt::Debug + Ord> fmt::Debug for BinaryHeap<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.debug_list().entries(self.iter()).finish()
}
}

impl<T: Ord> BinaryHeap<T> {
/// Creates an empty `BinaryHeap` as a max-heap.
///
Expand Down

0 comments on commit 8db906c

Please sign in to comment.