Skip to main content

Cell

Trait Cell 

Source
pub trait Cell: Display {
    type Truncated: Cell;
    type Padded: Cell;

    // Required methods
    fn width(&self) -> usize;
    fn truncate(&self, width: usize, delim: &str) -> Self::Truncated;
    fn pad(&self, width: usize) -> Self::Padded;

    // Provided method
    fn background(&self) -> Color { ... }
}
Expand description

Text that can be displayed on the terminal, measured, truncated and padded.

Required Associated Types§

Source

type Truncated: Cell

Type after truncation.

Source

type Padded: Cell

Type after padding.

Required Methods§

Source

fn width(&self) -> usize

Cell display width in number of terminal columns.

Source

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

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

Source

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

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

Provided Methods§

Source

fn background(&self) -> Color

Background color of cell.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Cell for String

Source§

type Truncated = String

Source§

type Padded = String

Source§

fn width(&self) -> usize

Source§

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

Source§

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

Source§

impl Cell for str

Source§

type Truncated = String

Source§

type Padded = String

Source§

fn width(&self) -> usize

Source§

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

Source§

fn pad(&self, max: usize) -> String

Source§

impl<T> Cell for &T
where T: Cell + ?Sized,

Source§

type Truncated = <T as Cell>::Truncated

Source§

type Padded = <T as Cell>::Padded

Source§

fn width(&self) -> usize

Source§

fn truncate(&self, width: usize, delim: &str) -> <&T as Cell>::Truncated

Source§

fn pad(&self, width: usize) -> <&T as Cell>::Padded

Implementors§