pub struct Highlight<O> { /* private fields */ }
Expand description
Highlight modifies a table style by changing a border of a target Table
segment.
§Example
use tabled::{TableIteratorExt, Highlight, Border, Style, object::Segment};
let data = [
("ELF", "Extensible Linking Format", true),
("DWARF", "", true),
("PE", "Portable Executable", false),
];
let table = data.iter()
.enumerate()
.table()
.with(Style::markdown())
.with(Highlight::new(Segment::all(), Border::default().top('^').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::{TableIteratorExt, Highlight, Border, Style, object::{Segment, Cell, Object}};
let data = [
("ELF", "Extensible Linking Format", true),
("DWARF", "", true),
("PE", "Portable Executable", false),
];
let table = data.iter()
.enumerate()
.table()
.with(Style::markdown())
.with(Highlight::new(Segment::all().not(Cell(0,0).and(Cell(1, 0).and(Cell(0, 1)).and(Cell(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§
Trait Implementations§
Auto Trait Implementations§
impl<O> Freeze for Highlight<O>where
O: Freeze,
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