Tablefy

Trait Tablefy 

Source
pub trait Tablefy {
    // Required methods
    fn get_headers() -> Vec<String>;
    fn into_vec(&self) -> Vec<String>;
}
Expand description

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

Required Methods§

Source

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.

Source

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();

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§