tabled::width

Struct MinWidth

Source
pub struct MinWidth<W = usize, P = PriorityNone> { /* private fields */ }
Expand description

MinWidth changes a content in case if it’s length is lower then the boundary.

It can be applied to a whole table.

It does nothing in case if the content’s length is bigger then the boundary.

Be aware that further changes of the table may cause the width being not set. For example applying Padding after applying MinWidth will make the former have no affect. (You should use Padding first).

Be aware that it doesn’t consider padding. So if you want to set a exact width you might need to use Padding to set it to 0.

§Examples

Cell change

use tabled::{object::Segment, Width, Modify, Style, Table};

let data = ["Hello", "World", "!"];

let table = Table::new(&data)
    .with(Style::markdown())
    .with(Modify::new(Segment::all()).with(Width::increase(10)));

Table change

use tabled::{Width, Table};

let table = Table::new(&["Hello World!"]).with(Width::increase(5));

Implementations§

Source§

impl<W> MinWidth<W>
where W: Measurment<Width>,

Source

pub fn new(width: W) -> Self

Creates a new instance of MinWidth.

Source§

impl<W, P> MinWidth<W, P>

Source

pub fn fill_with(self, c: char) -> Self

Set’s a fill character which will be used to fill the space when increasing the length of the string to the set boundary.

Used only if chaning cells.

Source

pub fn priority<PP: Peaker>(self) -> MinWidth<W, PP>

Priority defines the logic by which a increase of width will be applied when is done for the whole table.

Trait Implementations§

Source§

impl<W, R> CellOption<R> for MinWidth<W>

Source§

fn change_cell(&mut self, table: &mut Table<R>, entity: Entity)

Modification function of a single cell.
Source§

impl<W: Debug, P: Debug> Debug for MinWidth<W, P>

Source§

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

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

impl<W, P, R> TableOption<R> for MinWidth<W, P>

Source§

fn change(&mut self, table: &mut Table<R>)

The function modifies a Grid object.

Auto Trait Implementations§

§

impl<W, P> Freeze for MinWidth<W, P>
where W: Freeze,

§

impl<W, P> RefUnwindSafe for MinWidth<W, P>

§

impl<W, P> Send for MinWidth<W, P>
where W: Send, P: Send,

§

impl<W, P> Sync for MinWidth<W, P>
where W: Sync, P: Sync,

§

impl<W, P> Unpin for MinWidth<W, P>
where W: Unpin, P: Unpin,

§

impl<W, P> UnwindSafe for MinWidth<W, P>
where W: UnwindSafe, P: UnwindSafe,

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