Skip to main content

BoxChars

Struct BoxChars 

Source
pub struct BoxChars {
    pub top: [char; 4],
    pub head: [char; 4],
    pub head_row: [char; 4],
    pub mid: [char; 4],
    pub row: [char; 4],
    pub foot_row: [char; 4],
    pub foot: [char; 4],
    pub bottom: [char; 4],
    pub ascii: bool,
}
Expand description

Box drawing character set.

Each row is 4 characters: [left, middle, cross/divider, right]

  • left: leftmost edge character
  • middle: horizontal line character
  • cross: intersection or divider character
  • right: rightmost edge character

Fields§

§top: [char; 4]

Top row: ┌─┬┐

§head: [char; 4]

Head row (cell content): │ ││

§head_row: [char; 4]

Head separator: ├─┼┤

§mid: [char; 4]

Mid separator: ├─┼┤

§row: [char; 4]

Row separator: ├─┼┤

§foot_row: [char; 4]

Foot separator: ├─┼┤

§foot: [char; 4]

Foot row (cell content): │ ││

§bottom: [char; 4]

Bottom row: └─┴┘

§ascii: bool

Whether this box uses ASCII-only characters.

Implementations§

Source§

impl BoxChars

Source

pub const fn new( top: [char; 4], head: [char; 4], head_row: [char; 4], mid: [char; 4], row: [char; 4], foot_row: [char; 4], foot: [char; 4], bottom: [char; 4], ascii: bool, ) -> Self

Create a new box from character arrays.

Source

pub fn get_row_chars(&self, level: RowLevel) -> &[char; 4]

Get the row characters for a specific level.

Source

pub fn build_row(&self, widths: &[usize], level: RowLevel, edge: bool) -> String

Build a row string for the given column widths.

Source

pub fn get_top(&self, widths: &[usize]) -> String

Build the top border.

Source

pub fn get_bottom(&self, widths: &[usize]) -> String

Build the bottom border.

Source

pub fn get_head_row(&self, widths: &[usize]) -> String

Build the header separator.

Source

pub fn get_mid(&self, widths: &[usize]) -> String

Build a mid-table separator.

Source

pub fn get_row(&self, widths: &[usize]) -> String

Build a regular row separator.

Source

pub fn cell_left(&self) -> char

Get the cell left edge character.

Source

pub fn cell_divider(&self) -> char

Get the cell divider character.

Source

pub fn cell_right(&self) -> char

Get the cell right edge character.

Source

pub fn substitute(&self, safe: bool) -> &Self

Substitute characters for ASCII-safe rendering.

Trait Implementations§

Source§

impl Clone for BoxChars

Source§

fn clone(&self) -> BoxChars

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 BoxChars

Source§

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

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

impl Display for BoxChars

Source§

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

Formats the value using the given formatter. Read more

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
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> 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.