Struct duat_core::text::Builder

source ·
pub struct Builder { /* private fields */ }
Expand description

Builds and modifies a Text, based on replacements applied to it.

The generation of text by the [TextBuilder] has a few peculiarities that are convenient in the situations where it is useful:

  • The user cannot insert Tags directly, only by appending and modifying existing tags.
  • All Tags that are appended result in an inverse Tag being placed before the next one, or at the end of the [Tags] (e.g. Tag::PushForm would be followed a Tag::PopForm).
  • You can insert swappable text with [push_swappable()][Self::push_swappable].

These properties allow for quick and easy modification of the Text within, which can then be accessed with text.

Implementations§

source§

impl Builder

source

pub fn new() -> Self

source

pub fn finish(self) -> Text

source

pub fn push_str(&mut self, display: impl Display)

source

pub fn push_tag(&mut self, tag: Tag) -> Option<ToggleId>

Pushes a Tag to the end of the list of Tags, as well as its inverse at the end of the Text.

source

pub fn push_text(&mut self, text: Text)

source

pub fn push_part<D: Display>(&mut self, part: BuilderPart<D>)

source

pub fn clear(&mut self)

Trait Implementations§

source§

impl Default for Builder

source§

fn default() -> Self

Returns the “default value” for a type. Read more

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

§

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

§

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.