Struct tabled::FormatWithIndex[][src]

pub struct FormatWithIndex<F: FnMut(&str, usize, usize) -> String>(pub F);
Expand description

FormatWithIndex is like a Format. But it also provides a row and column index.

Example

use tabled::{Table, FormatWithIndex, Row, Modify};

let data = vec![
    (0, "Grodno", true),
    (1, "Minsk", true),
    (2, "Hamburg", false),
    (3, "Brest", true),
];

let table = Table::new(&data)
               .with(Modify::new(Row(..1))
                    .with(FormatWithIndex(|_, _, column| column.to_string())))
               .to_string();

assert_eq!(table, "+---+---------+-------+\n\
                   | 0 |    1    |   2   |\n\
                   +---+---------+-------+\n\
                   | 0 | Grodno  | true  |\n\
                   +---+---------+-------+\n\
                   | 1 |  Minsk  | true  |\n\
                   +---+---------+-------+\n\
                   | 2 | Hamburg | false |\n\
                   +---+---------+-------+\n\
                   | 3 |  Brest  | true  |\n\
                   +---+---------+-------+\n");

Tuple Fields

0: F

Trait Implementations

Modification function of a Cell

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.