Struct term_table::Table

source ·
pub struct Table {
    pub rows: Vec<Row>,
    pub style: TableStyle,
    pub max_column_width: usize,
    pub max_column_widths: HashMap<usize, usize>,
    pub separate_rows: bool,
    pub has_top_boarder: bool,
    pub has_bottom_boarder: bool,
}
Expand description

A set of rows containing data

Fields§

§rows: Vec<Row>§style: TableStyle§max_column_width: usize

The maximum width of all columns. Overridden by values in column_widths. Defaults to std::usize::max

§max_column_widths: HashMap<usize, usize>

The maximum widths of specific columns. Override max_column

§separate_rows: bool

Whether or not to vertically separate rows in the table

§has_top_boarder: bool

Whether the table should have a top boarder. Setting has_separator to false on the first row will have the same effect as setting this to false

§has_bottom_boarder: bool

Whether the table should have a bottom boarder

Implementations§

source§

impl Table

source

pub fn new() -> Table

source

pub fn builder() -> TableBuilder

source

pub fn with_rows(rows: Vec<Row>) -> Table

👎Deprecated since 1.4.0: Use builder instead
source

pub fn max_column_width(&mut self, max_column_width: usize) -> &mut Self

source

pub fn set_max_width_for_column(&mut self, column_index: usize, width: usize)

Set the max width of a particular column

source

pub fn set_max_column_widths(&mut self, index_width_pairs: Vec<(usize, usize)>)

Set the max widths of specific columns

source

pub fn add_row(&mut self, row: Row)

Simply adds a row to the rows Vec

source

pub fn render(&self) -> String

Does all of the calculations to reformat the row based on it’s current state and returns the result as a String

Trait Implementations§

source§

impl Clone for Table

source§

fn clone(&self) -> Table

Returns a copy 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 Table

source§

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

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

impl Default for Table

source§

fn default() -> Self

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

impl ToString for Table

source§

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementations§

§

impl Freeze for Table

§

impl RefUnwindSafe for Table

§

impl Send for Table

§

impl Sync for Table

§

impl Unpin for Table

§

impl UnwindSafe for Table

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§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

§

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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.