chore: custom debug for leaf & internal

This commit is contained in:
Zixuan Chen 2022-08-12 11:37:16 +08:00
parent e30ba86653
commit bd95ad42e4
3 changed files with 21 additions and 2 deletions

View file

@ -18,7 +18,6 @@ pub enum Node<'a, T: Rle, A: RleTreeTrait<T>> {
Leaf(BumpBox<'a, LeafNode<'a, T, A>>),
}
#[derive(Debug)]
pub struct InternalNode<'a, T: Rle, A: RleTreeTrait<T>> {
bump: &'a Bump,
parent: Option<NonNull<InternalNode<'a, T, A>>>,
@ -28,7 +27,6 @@ pub struct InternalNode<'a, T: Rle, A: RleTreeTrait<T>> {
_a: PhantomData<A>,
}
#[derive(Debug)]
pub struct LeafNode<'a, T: Rle, A: RleTreeTrait<T>> {
bump: &'a Bump,
parent: NonNull<InternalNode<'a, T, A>>,

View file

@ -1,3 +1,5 @@
use std::fmt::{Debug, Error, Formatter};
use crate::{rle_tree::tree_trait::Position, HasLength};
use super::*;
@ -396,3 +398,12 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> InternalNode<'a, T, A> {
}
}
}
impl<'a, T: Rle, A: RleTreeTrait<T>> Debug for InternalNode<'a, T, A> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
let mut debug_struct = f.debug_struct("InternalNode");
debug_struct.field("children", &self.children);
debug_struct.field("cache", &self.cache);
debug_struct.finish()
}
}

View file

@ -1,4 +1,5 @@
use crate::{rle_tree::tree_trait::Position, HasLength};
use std::fmt::{Debug, Error, Formatter};
use super::*;
@ -239,3 +240,12 @@ impl<'a, T: Rle, A: RleTreeTrait<T>> HasLength for LeafNode<'a, T, A> {
A::len_leaf(self)
}
}
impl<'a, T: Rle, A: RleTreeTrait<T>> Debug for LeafNode<'a, T, A> {
fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
let mut debug_struct = f.debug_struct("LeafNode");
debug_struct.field("children", &self.children);
debug_struct.field("cache", &self.cache);
debug_struct.finish()
}
}