Skip to main content

TableInit

Derive Macro TableInit 

Source
#[derive(TableInit)]
Expand description

Derive TableInit for tables

use std::collections::HashMap;
use step_p21_derive::{Holder, TableInit, as_holder};

#[derive(TableInit, Default)]
pub struct Table {
    a: HashMap<u64, as_holder!(A)>,
    b: HashMap<u64, as_holder!(B)>,
}

#[derive(Debug, Clone, PartialEq, Holder)]
#[holder(table = Table)]
#[holder(field = a)]
#[holder(generate_deserialize)]
pub struct A {
    pub x: f64,
    pub y: f64,
}

#[derive(Debug, Clone, PartialEq, Holder)]
#[holder(table = Table)]
#[holder(field = b)]
#[holder(generate_deserialize)]
pub struct B {
    pub z: f64,
    #[holder(use_place_holder)]
    pub a: A,
}