Add a few Debug impl

This commit is contained in:
Olivier Goffart 2020-08-10 17:25:15 +02:00
parent 3651d77a06
commit 681f304768
3 changed files with 23 additions and 1 deletions

View file

@ -437,6 +437,12 @@ pub struct VOffset<Base, T: ?Sized + VTableMeta, PinFlag = NotPinnedFlag> {
phantom: PhantomData<FieldOffset<Base, (), PinFlag>>,
}
impl<Base, T: ?Sized + VTableMeta, PinFlag> core::fmt::Debug for VOffset<Base, T, PinFlag> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "VOffset({})", self.offset)
}
}
impl<Base, T: ?Sized + VTableMeta, Flag> VOffset<Base, T, Flag> {
#[inline]
pub fn apply<'a>(self, x: &'a Base) -> VRef<'a, T> {

View file

@ -19,7 +19,7 @@ pub enum TraversalOrder {
/// -1 means the visitor will continue
/// otherwise this is the index of the item that aborted the visit.
#[repr(transparent)]
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[derive(Copy, Clone, Eq, PartialEq)]
pub struct VisitChildrenResult(i64);
impl VisitChildrenResult {
/// The result used for a visitor that want to continue the visit
@ -50,10 +50,20 @@ impl VisitChildrenResult {
}
}
}
impl core::fmt::Debug for VisitChildrenResult {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
if self.0 == -1 {
write!(f, "CONTINUE")
} else {
write!(f, "({},{})", (self.0 & 0xffff_ffff) as usize, (self.0 >> 32) as usize)
}
}
}
/// The item tree is an array of ItemTreeNode representing a static tree of items
/// within a component.
#[repr(u8)]
#[derive(Debug)]
pub enum ItemTreeNode<T> {
/// Static item
Item {

View file

@ -153,6 +153,12 @@ pub struct Instance {
_opaque: [u8; 0],
}
impl core::fmt::Debug for Instance {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Instance({:p})", self)
}
}
/// A pointer to an Instance that automaticaly frees the memory after use
pub struct InstanceBox(core::ptr::NonNull<Instance>);