pub struct Builder { /* private fields */ }Expand description
Builds and modifies a Text, based on replacements applied
to it.
This struct is meant to be used alongside the text! family of
macros. You pass it as the first argument, and the Text will
be extended by the macro. This lets you write a Text with
multiple macro invocations:
fn is_more_than_two(num: usize) -> Text {
let mut builder = Text::builder();
hint!(builder, "The number " [*a] num [] " is ");
if num > 2 {
hint!(builder, [*a] "more" [] " than 2.");
} else {
hint!(builder, [*a] "not more" [] " than 2.");
}
builder.finish()
}Implementations§
Source§impl Builder
impl Builder
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a new instance of Builder
Use Text::builder if you don’t want to bring Builder
into scope.
Sourcepub fn push<D: Display>(&mut self, part: impl Into<BuilderPart<D>>)
pub fn push<D: Display>(&mut self, part: impl Into<BuilderPart<D>>)
Pushes a part of the text
This can be an impl Display type, a Data type holding
an impl Display or a tag surrogate.
Sourcepub fn last_was_empty(&self) -> bool
pub fn last_was_empty(&self) -> bool
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl !RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl !UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more