Skip to main content

IndentWriter

Struct IndentWriter 

Source
pub struct IndentWriter { /* private fields */ }
Expand description

An indented text writer for emitting nested format text.

Provides a simple API for building indented, line-oriented output such as .proto files, GraphQL SDL, or TypeScript declarations.

Implementations§

Source§

impl IndentWriter

Source

pub const fn new(indent_str: &'static str) -> Self

Create a new IndentWriter with the given indentation string.

Common values: " " (2 spaces), " " (4 spaces), "\t".

Source

pub const fn indent(&mut self)

Increase the indentation level by one.

Source

pub const fn dedent(&mut self)

Decrease the indentation level by one.

Source

pub fn line(&mut self, s: &str)

Write a line at the current indentation level.

Source

pub fn blank(&mut self)

Write a blank line.

Source

pub fn raw(&mut self, s: &str)

Write raw text without indentation.

Source

pub fn finish(self) -> String

Consume the writer and return the built string.

Auto Trait Implementations§

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<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.