pub struct Indenter<'a, Opt: IndentedOptions<'a>> { /* private fields */ }
Expand description
The public face of the library, this is the type that must be created to use the crate::IndentedDisplay trait
This utilizes a std::fmt::Write formatter as its output, a base indent string that is used for all levels of indentation (unless overridden individually by indentation frames), and an options structure that contains options that may be interrogated by the implementation of crate::IndentedDisplay
Implementations§
Source§impl<'a, Opt: IndentedOptions<'a>> Indenter<'a, Opt>
impl<'a, Opt: IndentedOptions<'a>> Indenter<'a, Opt>
Sourcepub fn new(fmt: &'a mut (dyn Write + 'a), s: &'a str, options: &'a Opt) -> Self
pub fn new(fmt: &'a mut (dyn Write + 'a), s: &'a str, options: &'a Opt) -> Self
Create a new Indenter, to be used with types that implement the crate::IndentedDisplay trait; this specifies the formatter, the base indentation string, and the options for the indentation
Sourcepub fn sub(&self) -> Self
pub fn sub(&self) -> Self
Create a new subframe of the Indenter using its base
indentation for this indentation level; this is invoked by the
indent
function in an crate::IndentedDisplay trait implementation
to create subframes of indentation. The subframe is removed
from the indentation output stack when it is dropped, so it
must either go out of scope or be explicitly dropped.
Sourcepub fn push(&self, s: &'a str) -> Self
pub fn push(&self, s: &'a str) -> Self
Create a new subframe of the Indenter using a specific string,
indentation for this indentation level; this is invoked by the
indent
function in an crate::IndentedDisplay trait implementation
to create subframes of indentation. The subframe is removed
from the indentation output stack when it is dropped, so it
must either go out of scope or be explicitly dropped.
Currently the string must outlive the Indenter - usually this means it is static.
Sourcepub fn options(&self) -> &Opt
pub fn options(&self) -> &Opt
Borrow the options used to invoke the Indenter.
This may be invoked by the
indent
function in an crate::IndentedDisplay trait implementation
to determine the setting of indentation options that may affect its output.