pub trait DisplaySyntaxTree {
fn fmt(&self, level: usize, indent: usize, f: &mut core::fmt::Formatter<'_>)
-> core::fmt::Result;
#[cfg_attr(not(tarpaulin), inline(always))]
fn display(&self, level: usize, indent: usize) -> SyntaxTreeDisplay<'_, Self> {
SyntaxTreeDisplay {
t: self,
indent,
level,
}
}
}
impl<T: DisplaySyntaxTree + ?Sized> DisplaySyntaxTree for &T {
#[cfg_attr(not(tarpaulin), inline(always))]
fn fmt(
&self,
level: usize,
indent: usize,
f: &mut core::fmt::Formatter<'_>,
) -> core::fmt::Result {
(*self).fmt(level, indent, f)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct SyntaxTreeDisplay<'a, T: ?Sized> {
t: &'a T,
indent: usize,
level: usize,
}
impl<T: DisplaySyntaxTree + ?Sized> core::fmt::Display for SyntaxTreeDisplay<'_, T> {
#[cfg_attr(not(tarpaulin), inline(always))]
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
self.t.fmt(self.level, self.indent, f)
}
}