mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-02 06:50:32 +00:00
Merge #70
70: Implement Debug for `Queue`, `LinearMap` and `BinaryHeap` r=japaric a=XOSplicer # Description As pointed out in #56 the `fmt::Debug` implementation for those types is missing. This PR implements them by passing their respective `Iterator` to the formatter. # Open Questions - Should `Debug` also be implemented for `spsc::Consumer` and `spsc::Producer`? - Should the implementation for `BinaryHeap` respect the priority of the items in the heap? Co-authored-by: Felix Stegmaier <stegmaier.felix@gmail.com>
This commit is contained in:
commit
22b8d0809a
@ -11,7 +11,7 @@
|
||||
use core::cmp::Ordering;
|
||||
use core::marker::PhantomData;
|
||||
use core::mem::ManuallyDrop;
|
||||
use core::{mem, ptr, slice};
|
||||
use core::{mem, ptr, slice, fmt};
|
||||
|
||||
use generic_array::ArrayLength;
|
||||
|
||||
@ -412,6 +412,17 @@ impl<'a, T> Drop for Hole<'a, T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, N, K> fmt::Debug for BinaryHeap<T, N, K>
|
||||
where
|
||||
N: ArrayLength<T>,
|
||||
K: Kind,
|
||||
T: Ord + fmt::Debug
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_list().entries(self.iter()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, N, K> IntoIterator for &'a BinaryHeap<T, N, K>
|
||||
where
|
||||
N: ArrayLength<T>,
|
||||
|
@ -1,5 +1,5 @@
|
||||
use core::borrow::Borrow;
|
||||
use core::{mem, ops, slice};
|
||||
use core::{mem, ops, slice, fmt};
|
||||
|
||||
use generic_array::ArrayLength;
|
||||
|
||||
@ -390,6 +390,17 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<K, V, N> fmt::Debug for LinearMap<K, V, N>
|
||||
where
|
||||
N: ArrayLength<(K, V)>,
|
||||
K: Eq + fmt::Debug,
|
||||
V: fmt::Debug,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_map().entries(self.iter()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, K, V, N> IntoIterator for &'a LinearMap<K, V, N>
|
||||
where
|
||||
N: ArrayLength<(K, V)>,
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
use core::cell::UnsafeCell;
|
||||
use core::marker::PhantomData;
|
||||
use core::ptr;
|
||||
use core::{ptr, fmt};
|
||||
|
||||
use generic_array::{ArrayLength, GenericArray};
|
||||
|
||||
@ -216,6 +216,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, N, U, C> fmt::Debug for Queue<T, N, U, C>
|
||||
where
|
||||
N: ArrayLength<T>,
|
||||
T: fmt::Debug,
|
||||
U: sealed::Uxx,
|
||||
C: sealed::XCore,
|
||||
{
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
f.debug_list().entries(self.iter()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T, N, U, C> IntoIterator for &'a Queue<T, N, U, C>
|
||||
where
|
||||
N: ArrayLength<T>,
|
||||
|
Loading…
x
Reference in New Issue
Block a user