pub enum PaddingExpand {
Horizontal,
Vertical,
}
Expand description
PaddingExpand is able to expand padding to its limit a cell. Maybe usefull in cases were its colorization is supposed to be used next.
§Example
ⓘ
use std::iter::FromIterator;
use tabled::{
settings::{Padding, Style, Color, PaddingColor},
Table,
};
let char_split = |s: &str| s.chars().map(|c| c.to_string()).collect::<Vec<_>>();
let data = vec![
char_split("2021"),
char_split("2022"),
char_split("2023"),
char_split("2024"),
];
let table = Table::from_iter(&data)
.with(Style::ascii())
.with(PaddingColor::filled(Color::BG_BLUE))
.modify((2, 1), Padding::new(2, 2, 3, 3))
.with(Padding::expand(true))
.with(Padding::expand(false))
.to_string();
assert_eq!(
table,
concat!(
"+---+-----+---+---+\n",
"|2\u{1b}[44m \u{1b}[49m|0\u{1b}[44m \u{1b}[49m|2\u{1b}[44m \u{1b}[49m|1\u{1b}[44m \u{1b}[49m|\n",
"+---+-----+---+---+\n",
"|2\u{1b}[44m \u{1b}[49m|0\u{1b}[44m \u{1b}[49m|2\u{1b}[44m \u{1b}[49m|2\u{1b}[44m \u{1b}[49m|\n",
"+---+-----+---+---+\n",
"|2\u{1b}[44m \u{1b}[49m|0\u{1b}[44m \u{1b}[49m|2\u{1b}[44m \u{1b}[49m|3\u{1b}[44m \u{1b}[49m|\n",
"|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\n",
"|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\n",
"|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\n",
"|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\n",
"|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\n",
"|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\u{1b}[44m \u{1b}[49m|\n",
"+---+-----+---+---+\n",
"|2\u{1b}[44m \u{1b}[49m|0\u{1b}[44m \u{1b}[49m|2\u{1b}[44m \u{1b}[49m|4\u{1b}[44m \u{1b}[49m|\n",
"+---+-----+---+---+",
),
);
Variants§
Horizontal
Horizontal expansion of padding (LEFT and RIGHT)
Vertical
Vertical expansion of padding (TOP and BOTTOM)
Trait Implementations§
Source§impl<R> CellOption<R, ColoredConfig> for PaddingExpandwhere
R: Records + ExactRecords + PeekableRecords,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: AsRef<str>,
impl<R> CellOption<R, ColoredConfig> for PaddingExpandwhere
R: Records + ExactRecords + PeekableRecords,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: AsRef<str>,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, entity: Entity)
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>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreSource§impl Clone for PaddingExpand
impl Clone for PaddingExpand
Source§fn clone(&self) -> PaddingExpand
fn clone(&self) -> PaddingExpand
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for PaddingExpand
impl Debug for PaddingExpand
Source§impl Ord for PaddingExpand
impl Ord for PaddingExpand
Source§fn cmp(&self, other: &PaddingExpand) -> Ordering
fn cmp(&self, other: &PaddingExpand) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for PaddingExpand
impl PartialEq for PaddingExpand
Source§impl PartialOrd for PaddingExpand
impl PartialOrd for PaddingExpand
Source§impl<R, D> TableOption<R, ColoredConfig, D> for PaddingExpandwhere
R: Records + ExactRecords + PeekableRecords,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: AsRef<str>,
impl<R, D> TableOption<R, ColoredConfig, D> for PaddingExpandwhere
R: Records + ExactRecords + PeekableRecords,
for<'a> &'a R: Records,
for<'a> <<&'a R as Records>::Iter as IntoRecords>::Cell: AsRef<str>,
Source§fn change(self, records: &mut R, cfg: &mut ColoredConfig, _: &mut D)
fn change(self, records: &mut R, cfg: &mut ColoredConfig, _: &mut D)
The function modificaties of records and a grid configuration.
Source§fn hint_change(&self) -> Option<Entity>
fn hint_change(&self) -> Option<Entity>
A hint whether an
TableOption
is going to change table layout. Read moreimpl Copy for PaddingExpand
impl Eq for PaddingExpand
impl StructuralPartialEq for PaddingExpand
Auto Trait Implementations§
impl Freeze for PaddingExpand
impl RefUnwindSafe for PaddingExpand
impl Send for PaddingExpand
impl Sync for PaddingExpand
impl Unpin for PaddingExpand
impl UnwindSafe for PaddingExpand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more