pub fn truncate<T>(value: &T, limit: usize) -> Stringwhere
T: ToString,
Expand description
A function which truncates value to the given width.
ยงExample
use tabled::{Tabled, Table, derive::display};
use tabled::assert::assert_table;
#[derive(Tabled)]
pub struct ZKP<'a> {
#[tabled(display("display::truncate", 5))]
application: &'a str,
state: &'a str,
}
let data = vec![
ZKP { application: "Decentralized Identity", state: "Proved" },
ZKP { application: "Voting Systems", state: "Investigation" },
ZKP { application: "Privacy-Preserving Transactions", state: "" },
];
let table = Table::new(data);
assert_table!(
table,
"+-------------+---------------+"
"| application | state |"
"+-------------+---------------+"
"| Decen | Proved |"
"+-------------+---------------+"
"| Votin | Investigation |"
"+-------------+---------------+"
"| Priva | |"
"+-------------+---------------+"
);