pub enum TrimStrategy {
Vertical,
Horizontal,
Both,
None,
}
Expand description
TrimStrategy
determines if it’s allowed to use empty space while doing Alignment
.
§Examples
use tabled::{
Table,
settings::{
Style, Modify, Alignment, object::Segment,
formatting::{TrimStrategy, AlignmentStrategy}
}
};
let mut table = Table::new(&[" Hello World"]);
table
.with(Style::modern())
.with(
Modify::new(Segment::all())
.with(Alignment::left())
.with(TrimStrategy::Horizontal)
);
// Note that nothing was changed exactly.
assert_eq!(
table.to_string(),
"┌────────────────┐\n\
│ &str │\n\
├────────────────┤\n\
│ Hello World │\n\
└────────────────┘"
);
// To trim lines you would need also set [`AlignmentStrategy`].
table.with(Modify::new(Segment::all()).with(AlignmentStrategy::PerLine));
assert_eq!(
table.to_string(),
"┌────────────────┐\n\
│ &str │\n\
├────────────────┤\n\
│ Hello World │\n\
└────────────────┘"
);
let mut table = Table::new(&[" \n\n\n Hello World"]);
table
.with(Style::modern())
.with(
Modify::new(Segment::all())
.with(Alignment::center())
.with(Alignment::top())
.with(TrimStrategy::Vertical)
);
assert_eq!(
table.to_string(),
"┌─────────────────┐\n\
│ &str │\n\
├─────────────────┤\n\
│ Hello World │\n\
│ │\n\
│ │\n\
│ │\n\
└─────────────────┘"
);
Variants§
Vertical
Allow vertical trim.
Horizontal
Allow horizontal trim.
Both
Allow horizontal and vertical trim.
None
Doesn’t allow any trim.
Trait Implementations§
Source§impl<R> CellOption<R, ColoredConfig> for TrimStrategy
impl<R> CellOption<R, ColoredConfig> for TrimStrategy
Source§fn change(self, _: &mut R, cfg: &mut ColoredConfig, entity: Entity)
fn change(self, _: &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 TrimStrategy
impl Clone for TrimStrategy
Source§fn clone(&self) -> TrimStrategy
fn clone(&self) -> TrimStrategy
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 TrimStrategy
impl Debug for TrimStrategy
Source§impl Ord for TrimStrategy
impl Ord for TrimStrategy
Source§fn cmp(&self, other: &TrimStrategy) -> Ordering
fn cmp(&self, other: &TrimStrategy) -> 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 TrimStrategy
impl PartialEq for TrimStrategy
Source§impl PartialOrd for TrimStrategy
impl PartialOrd for TrimStrategy
Source§impl<R, D> TableOption<R, ColoredConfig, D> for TrimStrategy
impl<R, D> TableOption<R, ColoredConfig, D> for TrimStrategy
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 TrimStrategy
impl Eq for TrimStrategy
impl StructuralPartialEq for TrimStrategy
Auto Trait Implementations§
impl Freeze for TrimStrategy
impl RefUnwindSafe for TrimStrategy
impl Send for TrimStrategy
impl Sync for TrimStrategy
impl Unpin for TrimStrategy
impl UnwindSafe for TrimStrategy
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