Struct Line

Source
pub struct Line { /* private fields */ }
Expand description

A line of text that has styling and can be displayed.

Implementations§

Source§

impl Line

Source

pub fn new(item: impl Into<Label>) -> Self

Create a new line.

Source

pub fn blank() -> Self

Create a blank line.

Source

pub fn style(self, style: Style) -> Line

Return a styled line by styling all its labels.

Source

pub fn spaced(items: impl IntoIterator<Item = Label>) -> Self

Return a line with a single space between the given labels.

Source

pub fn item(self, item: impl Into<Label>) -> Self

Add an item to this line.

Source

pub fn extend(self, items: impl IntoIterator<Item = Label>) -> Self

Add multiple items to this line.

Source

pub fn push(&mut self, item: impl Into<Label>)

Add an item to this line.

Source

pub fn pad(&mut self, width: usize)

Pad this line to occupy the given width.

Source

pub fn truncate(&mut self, width: usize, delim: &str)

Truncate this line to the given width.

Source

pub fn width(&self) -> usize

Get the actual column width of this line.

Source

pub fn space(self) -> Self

Create a line that contains a single space.

Source

pub fn boxed(self) -> Box<dyn Element>

Box this line as an Element.

Source

pub fn filled(self, color: Color) -> Filled<Self>

Return a filled line.

Trait Implementations§

Source§

impl Cell for Line

Source§

type Truncated = Line

Type after truncation.
Source§

type Padded = Line

Type after padding.
Source§

fn width(&self) -> usize

Cell display width in number of terminal columns.
Source§

fn pad(&self, width: usize) -> Self::Padded

Pad the cell so that it is the given width, while keeping the content left-aligned.
Source§

fn truncate(&self, width: usize, delim: &str) -> Self::Truncated

Truncate cell if longer than given width. Shows the delimiter if truncated.
Source§

fn background(&self) -> Color

Background color of cell.
Source§

impl Clone for Line

Source§

fn clone(&self) -> Line

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Line

Source§

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

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

impl Default for Line

Source§

fn default() -> Line

Returns the “default value” for a type. Read more
Source§

impl Display for Line

Source§

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

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

impl Element for Line

Source§

fn size(&self, _parent: Constraint) -> Size

Get the size of the element, in rows and columns.
Source§

fn render(&self, _parent: Constraint) -> Vec<Line>

Render the element as lines of text that can be printed.
Source§

fn columns(&self, parent: Constraint) -> usize

Get the number of columns occupied by this element.
Source§

fn rows(&self, parent: Constraint) -> usize

Get the number of rows occupied by this element.
Source§

fn print(&self)

Print this element to stdout.
Source§

fn write(&self, constraints: Constraint) -> Result<()>
where Self: Sized,

Write using the given constraints to stdout.
Source§

fn display(&self, constraints: Constraint) -> String

Return a string representation of this element.
Source§

impl<T: Into<Label>> From<T> for Line

Source§

fn from(value: T) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Label>> for Line

Source§

fn from(items: Vec<Label>) -> Self

Converts to this type from the input type.
Source§

impl IntoIterator for Line

Source§

type Item = Label

The type of the elements being iterated over.
Source§

type IntoIter = Box<dyn Iterator<Item = Label>>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnwindSafe for Line

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
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,