pub struct Span { /* private fields */ }Expand description
A run of text in one style, on one line.
A span holds no character that is_unsafe
refuses, so no escape sequence, directional override, or line separator
reaches a terminal through it. It holds no tab either. A cluster never
spans two spans, so a line’s width is the sum of its spans’ widths.
Its Display prints the text without the style.
Implementations§
Source§impl Span
impl Span
Sourcepub fn new(text: impl AsRef<str>, style: Style) -> Self
pub fn new(text: impl AsRef<str>, style: Style) -> Self
A span of text in style.
Tabs expand to the next multiple of TAB_WIDTH
cells, counted from the start of the span. That is right for a span
that starts its line.
A span is one line, so every line break becomes a space, and the words around it stay apart. The line breaks are newline, carriage return, vertical tab, form feed, next line, and the line and paragraph separators. Every other unsafe character is removed.
Build text that spans lines, or follows other spans on a line, with
Text. It splits at each newline and counts tab stops
from the line start.
To keep an owned String as the span’s text when it needs no change,
use Span::from(string).
Trait Implementations§
impl Eq for Span
Source§impl Extend<Span> for Line
impl Extend<Span> for Line
Source§fn extend<I: IntoIterator<Item = Span>>(&mut self, spans: I)
fn extend<I: IntoIterator<Item = Span>>(&mut self, spans: I)
Source§fn extend_one(&mut self, item: T)
fn extend_one(&mut self, item: T)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)