pub struct Justification { /* private fields */ }
Expand description
Set a justification character and a color.
Default value is ' '
(<space>
) with no color.
§Examples
Setting a justification character.
use tabled::{
Table,
settings::formatting::Justification,
};
let mut table = Table::new(&[("Hello", ""), ("", "World")]);
table.with(Justification::new('#'));
assert_eq!(
table.to_string(),
"+-------+-------+\n\
| &str# | &str# |\n\
+-------+-------+\n\
| Hello | ##### |\n\
+-------+-------+\n\
| ##### | World |\n\
+-------+-------+"
);
Setting a justification color.
use tabled::{
Table,
settings::{formatting::Justification, Color},
};
let mut table = Table::new(&[("Hello", ""), ("", "World")]);
table.with(Justification::default().color(Color::BG_BRIGHT_RED));
assert_eq!(
table.to_string(),
"+-------+-------+\n\
| &str\u{1b}[101m \u{1b}[49m | &str\u{1b}[101m \u{1b}[49m |\n\
+-------+-------+\n\
| Hello | \u{1b}[101m \u{1b}[49m |\n\
+-------+-------+\n\
| \u{1b}[101m \u{1b}[49m | World |\n\
+-------+-------+"
);
Use different justification for different columns.
use tabled::{
Table,
settings::{Modify, object::Columns, formatting::Justification},
};
let mut table = Table::new(&[("Hello", ""), ("", "World")]);
table.with(Modify::new(Columns::one(0)).with(Justification::new('#')));
table.with(Modify::new(Columns::one(1)).with(Justification::new('@')));
assert_eq!(
table.to_string(),
"+-------+-------+\n\
| &str# | &str@ |\n\
+-------+-------+\n\
| Hello | @@@@@ |\n\
+-------+-------+\n\
| ##### | World |\n\
+-------+-------+"
);
Implementations§
Source§impl Justification
impl Justification
Trait Implementations§
Source§impl<R> CellOption<R, ColoredConfig> for Justification
impl<R> CellOption<R, ColoredConfig> for Justification
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 Justification
impl Clone for Justification
Source§fn clone(&self) -> Justification
fn clone(&self) -> Justification
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 Justification
impl Debug for Justification
Source§impl Default for Justification
impl Default for Justification
Source§fn default() -> Justification
fn default() -> Justification
Returns the “default value” for a type. Read more
Source§impl<R, D> TableOption<R, ColoredConfig, D> for Justification
impl<R, D> TableOption<R, ColoredConfig, D> for Justification
Source§fn change(self, _: &mut R, cfg: &mut ColoredConfig, _: &mut D)
fn change(self, _: &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 moreAuto Trait Implementations§
impl Freeze for Justification
impl RefUnwindSafe for Justification
impl Send for Justification
impl Sync for Justification
impl Unpin for Justification
impl UnwindSafe for Justification
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