[][src]Trait tablefy::Tablefy

pub trait Tablefy {
    fn get_headers() -> Vec<String>;
fn into_vec(&self) -> Vec<String>; }

The main trait of the library. Has two main functions with which a table can be constructed.

Required methods

fn get_headers() -> Vec<String>

Retrieves the headers of the table.

If derived, the headers will be the field names of the struct. Currently custom names aren't supported, but they may be implemented in the future.

fn into_vec(&self) -> Vec<String>

Turns the contents of a struct into a vector of strings.

If derived, all the contents are saved as a String. This is to facilitate displaying as a full table. However, in order for the derivation to work, all the fields of the struct must implement the Display trait. Otherwise the code won't compile.

struct Thing {
    name : String,
    age : i8,
    location : String
}
 
...
 
 
let items = thing.into_vec();
Loading content...

Implementors

Loading content...