Derive Macro memtable_macros::Table[][src]

    // Attributes available to this derive:
Expand description

Derives an implementation of the Table trait from memtable

Specifically, this produces a new struct to represent a table that can store the target data as rows within itself. This will also produce a unique data enum whose variants represent the different possible types outlined by individual fields.


use memtable_macros::Table;

struct User {
    name: String,
    age: u8,

let mut table = UserTable::new();

table.push_row(User {
    name: "Fred Flintstone".to_string(),
    age: 51,

table.push_row(User {
    name: "Wilma Flintstone".to_string(),
    age: 47,

// Retrieving data comes back as a tuple of all of the fields
let (name, age) = table.row(0).unwrap();
assert_eq!(name, "Fred Flintstone");
assert_eq!(*age, 51);