Implement Debug for BinaryHeap

Fixes #28154
This commit is contained in:
Simonas Kazlauskas 2015-09-01 20:26:51 +03:00
parent 05cc464d90
commit 8db906c752

View File

@ -154,6 +154,7 @@
use core::iter::{FromIterator};
use core::mem::swap;
use core::ptr;
use core::fmt;
use slice;
use vec::{self, Vec};
@ -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.
///