pub struct PrintableLines(/* private fields */);Expand description
Several lines of plain text, separated by \n.
A &str cannot say whether it holds plain text or already-rendered ANSI,
and a function that guesses has to guess on every call. That guessing is
what let escape handling leak into the plain path, so the property is
carried by this type instead: every line it holds is a
PrintableText, and the \n between them is a separator rather than
content.
It has no width. Width is a property of a row of cells, so it belongs to the lines this type splits into. Measuring across a line break would sum cells that never share a row.
Construction is where the caller declares the plain-text domain. Debug builds check the declaration; release builds take the caller’s word for it.
Implementations§
Source§impl PrintableLines
impl PrintableLines
Sourcepub fn new(text: &str) -> &Self
pub fn new(text: &str) -> &Self
Adopts plain text.
§Panics
In debug builds, panics when text holds a control character other
than \n — an escape sequence, a carriage return, a tab, a backspace.
Handing rendered output to a plain-text argument is a contract
violation, not a supported call with a degraded result: the layout pass
would measure the escapes as ordinary characters, and wrapping or
truncation would split them. Release builds do not check.
Sourcepub fn lines(&self) -> Vec<&PrintableText>
pub fn lines(&self) -> Vec<&PrintableText>
Splits into lines, yielding one empty line for empty text.
A view’s text always occupies at least one row, so an empty string measures as one empty line rather than as no line at all.
Trait Implementations§
Source§impl Debug for PrintableLines
impl Debug for PrintableLines
Source§impl PartialEq for PrintableLines
impl PartialEq for PrintableLines
Source§fn eq(&self, other: &PrintableLines) -> bool
fn eq(&self, other: &PrintableLines) -> bool
self and other values to be equal, and is used by ==.