pub struct Span<'a> {
pub content: Cow<'a, str>,
pub style: Option<Style>,
pub link: Option<Cow<'a, str>>,
}Expand description
A styled span of text.
Span is a simple wrapper around text and optional style, providing an ergonomic builder for creating styled text units.
Fields§
§content: Cow<'a, str>The text content.
style: Option<Style>Optional style for this span.
link: Option<Cow<'a, str>>Optional hyperlink URL (OSC 8).
Implementations§
Source§impl<'a> Span<'a>
impl<'a> Span<'a>
Sourcepub fn split_at_cell(&self, cell_pos: usize) -> (Self, Self)
pub fn split_at_cell(&self, cell_pos: usize) -> (Self, Self)
Split the span at a cell position.
Returns (left, right) where the split respects grapheme boundaries.
Sourcepub fn measurement(&self) -> TextMeasurement
pub fn measurement(&self) -> TextMeasurement
Return bounds-based measurement for this span.
Sourcepub fn with_style(self, style: Style) -> Self
pub fn with_style(self, style: Style) -> Self
Apply a style to this span.
Sourcepub fn into_segment(self) -> Segment<'a>
pub fn into_segment(self) -> Segment<'a>
Convert to a segment.
Sourcepub fn into_owned(self) -> Span<'static>
pub fn into_owned(self) -> Span<'static>
Convert to an owned span.
Trait Implementations§
Source§impl<'a> FromIterator<Span<'a>> for Text
impl<'a> FromIterator<Span<'a>> for Text
impl<'a> Eq for Span<'a>
impl<'a> StructuralPartialEq for Span<'a>
Auto Trait Implementations§
impl<'a> Freeze for Span<'a>
impl<'a> RefUnwindSafe for Span<'a>
impl<'a> Send for Span<'a>
impl<'a> Sync for Span<'a>
impl<'a> Unpin for Span<'a>
impl<'a> UnwindSafe for Span<'a>
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
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.