pub struct Colorization { /* private fields */ }
Expand description
Colorization
sets a color for the whole table data (so it’s not include the borders).
You can colorize borders in a different round using BorderColor
or Theme
§Examples
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::{style::BorderColor, themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let color3 = Color::FG_RED | Color::BG_RED;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::chess(color1, color2))
.with(Style::modern())
.with(BorderColor::filled(color3));
println!("{table}");
Implementations§
Source§impl Colorization
impl Colorization
Sourcepub fn chess(white: Color, black: Color) -> Self
pub fn chess(white: Color, black: Color) -> Self
Creates a Colorization
with a chess pattern.
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::{themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::chess(color1, color2))
.with(Style::empty());
println!("{table}");
Sourcepub fn exact<I, O>(colors: I, target: O) -> ExactColorization<O>
pub fn exact<I, O>(colors: I, target: O) -> ExactColorization<O>
Creates a Colorization
with a target Object
.
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::object::Rows;
use tabled::settings::{themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::exact([color1, color2], Rows::first()))
.with(Style::empty());
println!("{table}");
Sourcepub fn rows<I>(colors: I) -> Self
pub fn rows<I>(colors: I) -> Self
Creates a Colorization
with a pattern which changes row by row.
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::object::Rows;
use tabled::settings::{themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::rows([color1, color2]))
.with(Style::empty());
println!("{table}");
Sourcepub fn columns<I>(colors: I) -> Self
pub fn columns<I>(colors: I) -> Self
Creates a Colorization
with a pattern which changes column by column.
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::object::Rows;
use tabled::settings::{themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::columns([color1, color2]))
.with(Style::empty());
println!("{table}");
Sourcepub fn by_row<I>(colors: I) -> Self
pub fn by_row<I>(colors: I) -> Self
Creates a Colorization
with a pattern which peaks cells one by one iterating over rows.
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::object::Rows;
use tabled::settings::{themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::by_row([color1, color2]))
.with(Style::empty());
println!("{table}");
Sourcepub fn by_column<I>(colors: I) -> Self
pub fn by_column<I>(colors: I) -> Self
Creates a Colorization
with a pattern which peaks cells one by one iterating over columns.
use std::iter::FromIterator;
use tabled::builder::Builder;
use tabled::settings::object::Rows;
use tabled::settings::{themes::Colorization, Color, Style};
let data = [["Hello", "World"], ["Hi", "World"], ["Halo", "World"]];
let color1 = Color::FG_BLACK | Color::BG_WHITE;
let color2 = Color::BG_BLACK | Color::FG_WHITE;
let mut table = Builder::from_iter(data).build();
table
.with(Colorization::by_column([color1, color2]))
.with(Style::empty());
println!("{table}");
Trait Implementations§
Source§impl Clone for Colorization
impl Clone for Colorization
Source§fn clone(&self) -> Colorization
fn clone(&self) -> Colorization
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 Colorization
impl Debug for Colorization
Source§impl PartialEq for Colorization
impl PartialEq for Colorization
Source§impl<R, D> TableOption<R, ColoredConfig, D> for Colorizationwhere
R: Records + ExactRecords,
impl<R, D> TableOption<R, ColoredConfig, D> for Colorizationwhere
R: Records + ExactRecords,
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 Eq for Colorization
impl StructuralPartialEq for Colorization
Auto Trait Implementations§
impl Freeze for Colorization
impl RefUnwindSafe for Colorization
impl Send for Colorization
impl Sync for Colorization
impl Unpin for Colorization
impl UnwindSafe for Colorization
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