Struct indenter::Indented

source ·
pub struct Indented<'a, D: ?Sized> { /* private fields */ }
Expand description

Helper struct for efficiently indenting multi line display implementations

Explanation

This type will never allocate a string to handle inserting indentation. It instead leverages the write_str function that serves as the foundation of the core::fmt::Write trait. This lets it intercept each piece of output as its being written to the output buffer. It then splits on newlines giving slices into the original string. Finally we alternate writing these lines and the specified indentation to the output buffer.

Implementations§

Sets the format to Format::Numbered with the provided index

Sets the format to Format::Uniform with the provided static string

Construct an indenter with a user defined format

Trait Implementations§

Writes a string slice into this writer, returning whether the write succeeded. Read more
Writes a char into this writer, returning whether the write succeeded. Read more
Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.