pub struct Highlight<O> { /* private fields */ }
Available on crate feature
std
only.Expand description
Highlight modifies a table style by changing a border of a target Table
segment.
Example
use tabled::{
Table,
settings::{Highlight, Border, Style, object::Segment}
};
let data = [
("ELF", "Extensible Linking Format", true),
("DWARF", "", true),
("PE", "Portable Executable", false),
];
let table = Table::new(data.iter().enumerate())
.with(Style::markdown())
.with(Highlight::border(Segment::all(), Border::new().set_top('^').set_bottom('v')))
.to_string();
assert_eq!(
table,
concat!(
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ \n",
"| usize | &str | &str | bool |\n",
"|-------|-------|---------------------------|-------|\n",
"| 0 | ELF | Extensible Linking Format | true |\n",
"| 1 | DWARF | | true |\n",
"| 2 | PE | Portable Executable | false |\n",
" vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv ",
),
);
It’s possible to use Highlight
for many kinds of figures.
use tabled::{
Table,
settings::{
Highlight, Border, Style,
object::{Segment, Object}
}
};
let data = [
("ELF", "Extensible Linking Format", true),
("DWARF", "", true),
("PE", "Portable Executable", false),
];
let table = Table::new(data.iter().enumerate())
.with(Style::markdown())
.with(Highlight::border(Segment::all().not((0,0).and((1, 0)).and((0, 1)).and((0, 3))), Border::filled('*')))
.to_string();
println!("{}", table);
assert_eq!(
table,
concat!(
" ***************************** \n",
"| usize | &str * &str * bool |\n",
"|-------*********---------------------------*********\n",
"| 0 * ELF | Extensible Linking Format | true *\n",
"********* *\n",
"* 1 | DWARF | | true *\n",
"* *\n",
"* 2 | PE | Portable Executable | false *\n",
"*****************************************************",
),
);
Implementations§
source§impl<O> Highlight<O>
impl<O> Highlight<O>
sourcepub const fn border<T, B, L, R>(target: O, border: Border<T, B, L, R>) -> Self
pub const fn border<T, B, L, R>(target: O, border: Border<T, B, L, R>) -> Self
Build a new instance of Highlight
BE AWARE: if target exceeds boundaries it may panic.
sourcepub fn color<T, B, L, R>(target: O, border: BorderColor<T, B, L, R>) -> Self
pub fn color<T, B, L, R>(target: O, border: BorderColor<T, B, L, R>) -> Self
Build a new instance of Highlight
BE AWARE: if target exceeds boundaries it may panic.
sourcepub const fn outline(target: O, c: char) -> Self
pub const fn outline(target: O, c: char) -> Self
Build a new instance of Highlight
BE AWARE: if target exceeds boundaries it may panic.
sourcepub fn colored_outline<T, B, L, R>(target: O, c: char, color: Color) -> Self
pub fn colored_outline<T, B, L, R>(target: O, c: char, color: Color) -> Self
Build a new instance of Highlight
BE AWARE: if target exceeds boundaries it may panic.
sourcepub fn colored_border<T, B, L, R>(
target: O,
border: Border<T, B, L, R>,
color: BorderColor<T, B, L, R>
) -> Self
pub fn colored_border<T, B, L, R>( target: O, border: Border<T, B, L, R>, color: BorderColor<T, B, L, R> ) -> Self
Build a new instance of Highlight
BE AWARE: if target exceeds boundaries it may panic.
Trait Implementations§
source§impl<O, R, D> TableOption<R, ColoredConfig, D> for Highlight<O>
impl<O, R, D> TableOption<R, ColoredConfig, D> for Highlight<O>
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 moreAuto Trait Implementations§
impl<O> RefUnwindSafe for Highlight<O>where
O: RefUnwindSafe,
impl<O> Send for Highlight<O>where
O: Send,
impl<O> Sync for Highlight<O>where
O: Sync,
impl<O> Unpin for Highlight<O>where
O: Unpin,
impl<O> UnwindSafe for Highlight<O>where
O: UnwindSafe,
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