pub struct StyledText { /* private fields */ }Expand description
A sequence of styled spans representing rich text.
Can be constructed from plain &str / String (unstyled),
a single Span, or a Vec<Span>.
Layout concatenates all spans before grapheme segmentation. Splitting a grapheme cluster across spans is supported for width and wrapping, but the cluster uses the style active at its first scalar value.
Implementations§
Source§impl StyledText
impl StyledText
Sourcepub fn new() -> StyledText
pub fn new() -> StyledText
Creates an empty styled text sequence.
Sourcepub fn spans_mut(&mut self) -> &mut [Span]
pub fn spans_mut(&mut self) -> &mut [Span]
Returns mutable access to the spans in this text sequence.
Sourcepub fn char_count(&self) -> usize
pub fn char_count(&self) -> usize
Total display width in terminal columns.
Wide characters and emoji grapheme clusters count as terminal columns, not Unicode scalar values.
Trait Implementations§
Source§impl Clone for StyledText
impl Clone for StyledText
Source§fn clone(&self) -> StyledText
fn clone(&self) -> StyledText
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for StyledText
impl Debug for StyledText
Source§impl Default for StyledText
impl Default for StyledText
Source§fn default() -> StyledText
fn default() -> StyledText
Returns the “default value” for a type. Read more
impl Eq for StyledText
Source§impl From<&str> for StyledText
impl From<&str> for StyledText
Source§fn from(s: &str) -> StyledText
fn from(s: &str) -> StyledText
Converts to this type from the input type.
Source§impl From<Span> for StyledText
impl From<Span> for StyledText
Source§fn from(span: Span) -> StyledText
fn from(span: Span) -> StyledText
Converts to this type from the input type.
Source§impl From<String> for StyledText
impl From<String> for StyledText
Source§fn from(s: String) -> StyledText
fn from(s: String) -> StyledText
Converts to this type from the input type.
Source§impl From<StyledText> for StyledBlock
impl From<StyledText> for StyledBlock
Source§fn from(text: StyledText) -> StyledBlock
fn from(text: StyledText) -> StyledBlock
Converts to this type from the input type.
Source§impl PartialEq for StyledText
impl PartialEq for StyledText
impl StructuralPartialEq for StyledText
Auto Trait Implementations§
impl Freeze for StyledText
impl RefUnwindSafe for StyledText
impl Send for StyledText
impl Sync for StyledText
impl Unpin for StyledText
impl UnsafeUnpin for StyledText
impl UnwindSafe for StyledText
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