pub struct TreeFormatter { /* private fields */ }Implementations§
Source§impl TreeFormatter
impl TreeFormatter
Sourcepub fn root(&mut self, content: &str) -> Result
pub fn root(&mut self, content: &str) -> Result
Display a root node (no indentation prefix). Only use this for the very top-level node.
Sourcepub fn field(&mut self, is_last: bool, name: &str, value: &str) -> Result
pub fn field(&mut self, is_last: bool, name: &str, value: &str) -> Result
Display a field with a name and value.
Sourcepub fn field_with_child<T: TreeDisplay>(
&mut self,
is_last: bool,
name: &str,
value: &T,
source: &str,
) -> Result
pub fn field_with_child<T: TreeDisplay>( &mut self, is_last: bool, name: &str, value: &T, source: &str, ) -> Result
Display a field with a child node that implements TreeDisplay.
Sourcepub fn field_option<T: TreeDisplay>(
&mut self,
is_last: bool,
name: &str,
value: &Option<T>,
source: &str,
) -> Result
pub fn field_option<T: TreeDisplay>( &mut self, is_last: bool, name: &str, value: &Option<T>, source: &str, ) -> Result
Display an optional field.
Sourcepub fn field_vec<T: TreeDisplay>(
&mut self,
is_last: bool,
name: &str,
items: &[T],
source: &str,
) -> Result
pub fn field_vec<T: TreeDisplay>( &mut self, is_last: bool, name: &str, items: &[T], source: &str, ) -> Result
Display a vector of items.
Sourcepub fn field_array<T: TreeDisplay, const N: usize>(
&mut self,
is_last: bool,
name: &str,
items: &[T; N],
source: &str,
) -> Result
pub fn field_array<T: TreeDisplay, const N: usize>( &mut self, is_last: bool, name: &str, items: &[T; N], source: &str, ) -> Result
Display an array of items.
Sourcepub fn field_tuple2<T1: TreeDisplay, T2: TreeDisplay>(
&mut self,
is_last: bool,
name: &str,
value: &(T1, T2),
source: &str,
) -> Result
pub fn field_tuple2<T1: TreeDisplay, T2: TreeDisplay>( &mut self, is_last: bool, name: &str, value: &(T1, T2), source: &str, ) -> Result
Display a tuple of 2 items.
Sourcepub fn format_raw(&self, span: Span, source: &str) -> String
pub fn format_raw(&self, span: Span, source: &str) -> String
Extract and format raw source text from a span.
If the text is longer than 40 characters, it will be truncated to show the first 20 and last 20 characters with “…” in the middle. Newlines and other whitespace are normalized to single spaces.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TreeFormatter
impl RefUnwindSafe for TreeFormatter
impl Send for TreeFormatter
impl Sync for TreeFormatter
impl Unpin for TreeFormatter
impl UnsafeUnpin for TreeFormatter
impl UnwindSafe for TreeFormatter
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more