Crate ruststep_derive[][src]

Expand description

Procedural macros for ruststep

use ruststep_derive::{as_holder, Holder};
use std::collections::HashMap;

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)]
pub struct A {
    pub x: f64,
    pub y: f64,
}

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

#[derive(Holder)] generates followings:

  • AHolder struct

    • naming rule is {}Holder
    • This name is obtained by as_holder!(A)
  • impl Holder for AHolder

  • impl Deserialize for AHolder

  • AHolderVisitor struct for implementing serde::Deserialize trait

    • naming rule is {}HolderVisitor
    • This name is obtained by as_holder_visitor!(A)
    • This struct is usually generated by serde_derive::Deserialize proc-macro, but their definition does not match for our cases.

Macros

Resolve Holder struct from owned type, e.g. A to AHolder

Resolve HolderVisitor struct from owned type, e.g. A to AHolderVisitor

Derive Macros

Generate impl Deserialize for entity structs