Skip to main content

PrintItems

Struct PrintItems 

Source
pub struct PrintItems<'a> { /* private fields */ }
Expand description

A list of print items allocated in an Arena.

Implementations§

Source§

impl<'a> PrintItems<'a>

Source

pub fn new(arena: &'a Arena) -> Self

Source

pub fn arena(&self) -> &'a Arena

Gets the arena the print items are allocated in.

Source

pub fn into_rc_path(self) -> Option<PrintItemPath<'a>>

Source

pub fn push_item(&mut self, item: PrintItem<'a>)

Source

pub fn extend(&mut self, items: PrintItems<'a>)

Source

pub fn push_str_runtime_width_computed(&mut self, item: &'a str)

Pushes a string that will have its width computed at runtime.

The string isn’t copied, so this can be used for text that lives at least as long as the arena, such as the text of the file being formatted.

Instead of using this, prefer to use push_sc where possible with the sc! macro from the dprint-core-macros crate.

Source

pub fn push_force_current_line_indentation(&mut self)

Source

pub fn push_space(&mut self)

Source

pub fn push_sc(&mut self, item: &'a StringContainer<'a>)

Pushes a string that’s had its width computed at compile time.

Source

pub fn push_string(&mut self, item: String)

Pushes a string, copying it into the arena.

Source

pub fn push_str(&mut self, item: &str)

Pushes a borrowed string, copying it into the arena, and computes its width at runtime.

Prefer push_sc with the sc! macro for text known at compile time, and push_str_runtime_width_computed for text that lives as long as the arena, since neither copies. Use this for other text the caller doesn’t own: it avoids building a String only for it to be copied and thrown away.

Source

pub fn push_condition(&mut self, condition: Condition<'a>)

Source

pub fn push_info(&mut self, info: impl Into<Info>)

Source

pub fn push_line_and_column(&mut self, line_and_col: LineAndColumn)

Source

pub fn push_anchor(&mut self, anchor: impl Into<Anchor>)

Source

pub fn push_reevaluation( &mut self, condition_reevaluation: ConditionReevaluation, )

Source

pub fn push_signal(&mut self, signal: Signal)

Source

pub fn push_path(&mut self, path: PrintItemPath<'a>)

Source

pub fn push_optional_path(&mut self, path: Option<PrintItemPath<'a>>)

Source

pub fn is_empty(&self) -> bool

Source

pub fn get_as_text(&self) -> String

Source

pub fn iter(&self) -> PrintItemsIterator<'a> ⓘ

Trait Implementations§

Source§

impl<'a> IntoPrintItems<'a> for PrintItems<'a>

Source§

fn into_print_items(self, _arena: &'a Arena) -> PrintItems<'a>

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for PrintItems<'a>

§

impl<'a> !Send for PrintItems<'a>

§

impl<'a> !Sync for PrintItems<'a>

§

impl<'a> !UnwindSafe for PrintItems<'a>

§

impl<'a> Forget for PrintItems<'a>

§

impl<'a> Freeze for PrintItems<'a>

§

impl<'a> Move for PrintItems<'a>

§

impl<'a> Unpin for PrintItems<'a>

§

impl<'a> UnsafeUnpin for PrintItems<'a>

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.