pub struct TextRun(/* private fields */);Expand description
Body of a text-mode command. Adjacent Str items are merged, no Str is
empty, and no Space follows a Space.
Implementations§
Source§impl TextRun
impl TextRun
Sourcepub fn new(items: Vec<TextItem>) -> Self
pub fn new(items: Vec<TextItem>) -> Self
Creates a new TextRun from a vector of items, enforcing invariants.
Sourcepub fn plain(s: &str) -> Self
pub fn plain(s: &str) -> Self
Creates a TextRun from a plain string, converting spaces to Space items.
Sourcepub fn push_char(&mut self, c: char)
pub fn push_char(&mut self, c: char)
Appends a character to the last Str item or creates a new one.
Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns Some only when the run contains exactly one Str item.
Sourcepub fn to_plain_string(&self) -> String
pub fn to_plain_string(&self) -> String
Converts the run to a plain string representation.
Trait Implementations§
impl Eq for TextRun
impl StructuralPartialEq for TextRun
Auto Trait Implementations§
impl Forget for TextRun
impl Freeze for TextRun
impl RefUnwindSafe for TextRun
impl Send for TextRun
impl Sync for TextRun
impl Unpin for TextRun
impl UnsafeUnpin for TextRun
impl UnwindSafe for TextRun
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more