pub struct TextSpans { /* private fields */ }Expand description
An encoded list of spans, ready to travel.
Shared rather than copied, for the same reason a draw list is: the same list redrawn every frame compares equal and produces no mutation at all.
Implementations§
Source§impl TextSpans
impl TextSpans
pub fn new(spans: impl IntoIterator<Item = TextSpan>) -> Self
Sourcepub fn from_bytes(bytes: impl Into<Rc<[u8]>>) -> Self
pub fn from_bytes(bytes: impl Into<Rc<[u8]>>) -> Self
Adopts an already encoded list, which is what the protocol vectors carry.
pub fn as_bytes(&self) -> &[u8] ⓘ
pub fn is_empty(&self) -> bool
Sourcepub fn spans(&self) -> impl Iterator<Item = TextSpan> + '_
pub fn spans(&self) -> impl Iterator<Item = TextSpan> + '_
The runs this list holds, decoded again.
Sourcepub fn from_markdown(source: &str) -> (String, Self)
pub fn from_markdown(source: &str) -> (String, Self)
Turns a small, closed subset of markdown into a plain string and its spans.
**bold**, *italic* and `code`, and nothing else. It is a convenience, not
a parser: anything it does not recognise is left in the string exactly as written,
because silently eating a character a reader typed is worse than showing it.
Links are not here. A link needs a handler, and a handler is something the screen has rather than something a string can name.
Trait Implementations§
impl StructuralPartialEq for TextSpans
Auto Trait Implementations§
impl !Send for TextSpans
impl !Sync for TextSpans
impl Freeze for TextSpans
impl RefUnwindSafe for TextSpans
impl Unpin for TextSpans
impl UnsafeUnpin for TextSpans
impl UnwindSafe for TextSpans
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