Function empty

Source
pub fn empty<T>(_value: &T) -> String
Expand description

A function which is usefull in conjuntion with #[tabled(display)] and #[tabled(display)].

It just returns an empty string.

use tabled::{Tabled, Table, derive::display};
use tabled::assert::assert_table;

#[derive(Tabled)]
pub struct ZKP<'a> {
    application: &'a str,
    #[tabled(display = "display::empty")]
    state: Option<&'a str>
}

let data = vec![
    ZKP { application: "Decentralized Identity", state: Some("Proved") },
    ZKP { application: "Voting Systems", state: Some("Investigation") },
    ZKP { application: "Privacy-Preserving Transactions", state: None },
];

let table = Table::new(data);

assert_table!(
    table,
    r#"+---------------------------------+-------+"#
    r#"| application                     | state |"#
    r#"+---------------------------------+-------+"#
    r#"| Decentralized Identity          |       |"#
    r#"+---------------------------------+-------+"#
    r#"| Voting Systems                  |       |"#
    r#"+---------------------------------+-------+"#
    r#"| Privacy-Preserving Transactions |       |"#
    r#"+---------------------------------+-------+"#
);