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::{Table, settings::{object::Segment, Width, Style, Modify}};

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::{Table, settings::Width};

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

Implementations§

Source§

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

Source

pub const 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 changing cells.

Source

pub fn priority<PP: Peaker>(self, peacker: PP) -> 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, P> CellOption<R, ColoredConfig> for MinWidth<W, P>

Source§

fn change(self, records: &mut R, cfg: &mut ColoredConfig, entity: Entity)

Modification function of a certail part of a grid targeted by Entity.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

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

Source§

fn clone(&self) -> MinWidth<W, P>

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<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: Ord, P: Ord> Ord for MinWidth<W, P>

Source§

fn cmp(&self, other: &MinWidth<W, P>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

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

Source§

fn eq(&self, other: &MinWidth<W, P>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

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

Source§

fn partial_cmp(&self, other: &MinWidth<W, P>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

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

Source§

fn change( self, records: &mut R, cfg: &mut ColoredConfig, dims: &mut CompleteDimension, )

The function modificaties of records and a grid configuration.
Source§

fn hint_change(&self) -> Option<Entity>

A hint whether an TableOption is going to change table layout. Read more
Source§

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

Source§

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

Source§

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

Auto Trait Implementations§

§

impl<W, P> Freeze for MinWidth<W, P>
where W: Freeze, P: 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> 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, 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.