Struct indenter::CodeFormatter [−][src]
Helper struct for efficiently dedent and indent multi line display implementations
Explanation
This type allocates a string once to get the formatted result and then uses the internal formatter efficiently to: first dedent the output, then re-indent to the desired level.
Implementations
impl<'a, T: Write> CodeFormatter<'a, T>
[src]
pub fn new<S: Into<String>>(f: &'a mut T, indentation: S) -> Self
[src]
Wrap the formatter f
, use indentation
as base string indentation and return a new
formatter that implements std::fmt::Write
that can be used with the macro write!()
pub fn set_level(&mut self, level: u32)
[src]
Set the indentation level to a specific value
pub fn indent(&mut self, inc: u32)
[src]
Increase the indentation level by inc
pub fn dedent(&mut self, inc: u32)
[src]
Decrease the indentation level by inc
Trait Implementations
impl<'a, T: Write> Write for CodeFormatter<'a, T>
[src]
Auto Trait Implementations
impl<'a, T> RefUnwindSafe for CodeFormatter<'a, T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<'a, T> Send for CodeFormatter<'a, T> where
T: Send,
T: Send,
impl<'a, T> Sync for CodeFormatter<'a, T> where
T: Sync,
T: Sync,
impl<'a, T> Unpin for CodeFormatter<'a, T>
impl<'a, T> !UnwindSafe for CodeFormatter<'a, T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,