chore: refine debug info

This commit is contained in:
Zixuan Chen 2022-08-13 01:05:14 +08:00
parent 3b091d8891
commit ec209f233e
3 changed files with 13 additions and 1 deletions

View file

@ -1,4 +1,5 @@
use std::{
fmt::Debug,
marker::{PhantomData, PhantomPinned},
ptr::NonNull,
};
@ -12,7 +13,7 @@ mod internal_impl;
mod leaf_impl;
pub(crate) mod node_trait;
#[derive(Debug, EnumAsInner)]
#[derive(EnumAsInner)]
pub enum Node<'a, T: Rle, A: RleTreeTrait<T>> {
Internal(InternalNode<'a, T, A>),
Leaf(LeafNode<'a, T, A>),
@ -250,3 +251,12 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> HasLength for Node<'a, T, A> {
}
}
}
impl<'a, T: Rle, A: RleTreeTrait<T>> Debug for Node<'a, T, A> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Internal(arg0) => arg0.fmt(f),
Self::Leaf(arg0) => arg0.fmt(f),
}
}
}

View file

@ -401,6 +401,7 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> Debug for InternalNode<'a, T, A> {
let mut debug_struct = f.debug_struct("InternalNode");
debug_struct.field("children", &self.children);
debug_struct.field("cache", &self.cache);
debug_struct.field("children_num", &self.children.len());
debug_struct.finish()
}
}

View file

@ -258,6 +258,7 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> Debug for LeafNode<'a, T, A> {
let mut debug_struct = f.debug_struct("LeafNode");
debug_struct.field("children", &self.children);
debug_struct.field("cache", &self.cache);
debug_struct.field("children_num", &self.children.len());
debug_struct.finish()
}
}