Skip to main content

Indent

Struct Indent 

Source
pub struct Indent<'f, F: Write + ?Sized> {
    indent: &'static str,
    needs_indent: bool,
    f: &'f mut F,
}
Expand description

Pads text with leading indentation after every newline

Fields§

§indent: &'static str§needs_indent: bool§f: &'f mut F

Implementations§

Source§

impl<'f, F: Write + ?Sized> Indent<'f, F>

Source

pub const fn new(f: &'f mut F, indent: &'static str) -> Self

Source

pub const fn inner(&mut self) -> &mut F

Gets mutable access to the inner Write-adapter

Trait Implementations§

Source§

impl<F: Write + ?Sized> Write for Indent<'_, F>

Source§

fn write_str(&mut self, s: &str) -> Result

Writes a string slice into this writer, returning whether the write succeeded. Read more
Source§

fn write_char(&mut self, c: char) -> Result

Writes a char into this writer, returning whether the write succeeded. Read more
1.0.0 · Source§

fn write_fmt(&mut self, args: Arguments<'_>) -> Result<(), Error>

Glue for usage of the write! macro with implementors of this trait. Read more

Auto Trait Implementations§

§

impl<'f, F> Freeze for Indent<'f, F>
where F: ?Sized,

§

impl<'f, F> RefUnwindSafe for Indent<'f, F>
where F: RefUnwindSafe + ?Sized,

§

impl<'f, F> Send for Indent<'f, F>
where F: Send + ?Sized,

§

impl<'f, F> Sync for Indent<'f, F>
where F: Sync + ?Sized,

§

impl<'f, F> Unpin for Indent<'f, F>
where F: ?Sized,

§

impl<'f, F> !UnwindSafe for Indent<'f, F>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<W> FmtAdapter for W
where W: Write + ?Sized,

Source§

fn indent(&mut self) -> Indent<'_, Self>

Indents by one level.
Source§

fn indent_with(&mut self, indent: &'static str) -> Indent<'_, Self>

Pastes indent after each newline.
Source§

fn delimit<O: Display, E: Display>( &mut self, open: O, close: E, ) -> Delimit<'_, Self, E>

Delimits a section with open and close.
Source§

fn delimit_indented<O: Display, E: Display>( &mut self, open: O, close: E, ) -> DelimitIndent<'_, Self, E>

Delimits a section with open and close, raising the indent level within.
Source§

fn list<Item: Display, Sep: Display>( &mut self, items: &[Item], sep: Sep, ) -> Result

Formats bracketed lists of the kind (Item (Comma Item)*)?
Source§

fn list_end<Item: Display, Sep: Display, End: Display>( &mut self, items: &[Item], sep: Sep, end: End, ) -> Result

Source§

fn list_wrap<Item: Display, Sep: Display, O: Display, E: Display>( &mut self, open: O, items: &[Item], sep: Sep, close: E, ) -> Result

Wraps a list in open and close. This differs from FmtAdapter::delimit because it prints nothing if the list is empty.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.