Skip to main content

PrintableLines

Struct PrintableLines 

Source
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

Source

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.

Source

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

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PrintableLines

Source§

fn eq(&self, other: &PrintableLines) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for PrintableLines

Source§

impl StructuralPartialEq for PrintableLines

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more