pub struct Concat { /* private fields */ }
Available on crate feature
std
only.Expand description
Concat
concatenates tables along a particular axis [Horizontal | Vertical].
It doesn’t do any key or column comparisons like SQL’s join does.
When the tables has different sizes, empty cells will be created by default.
Concat
in horizontal mode has similar behaviour to tuples (a, b)
.
But it behaves on tables rather than on an actual data.
Concat
DOES NOT handle style merge and other configuration of 2nd table,
it just uses 1st one as a bases.
Example
use tabled::{Table, Tabled, settings::{Style, Concat}};
#[derive(Tabled)]
struct Message {
id: &'static str,
text: &'static str,
}
#[derive(Tabled)]
struct Department(#[tabled(rename = "department")] &'static str);
let messages = [
Message { id: "0", text: "Hello World" },
Message { id: "1", text: "Do do do something", },
];
let departments = [
Department("Admins"),
Department("DevOps"),
Department("R&D"),
];
let mut table = Table::new(messages);
table
.with(Concat::horizontal(Table::new(departments)))
.with(Style::extended());
assert_eq!(
table.to_string(),
concat!(
"╔════╦════════════════════╦════════════╗\n",
"║ id ║ text ║ department ║\n",
"╠════╬════════════════════╬════════════╣\n",
"║ 0 ║ Hello World ║ Admins ║\n",
"╠════╬════════════════════╬════════════╣\n",
"║ 1 ║ Do do do something ║ DevOps ║\n",
"╠════╬════════════════════╬════════════╣\n",
"║ ║ ║ R&D ║\n",
"╚════╩════════════════════╩════════════╝",
)
)
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for Concat
impl Send for Concat
impl Sync for Concat
impl Unpin for Concat
impl UnwindSafe for Concat
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