rango-orm-derive 0.2.0

#[derive(Model)] proc-macro for Rango ORM
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::rango_core_path;
use proc_macro2::TokenStream;
use quote::quote;
use syn::{DeriveInput, Result};

/// Expand `#[derive(ModelMixin)]`.
pub fn expand(input: DeriveInput) -> Result<TokenStream> {
    let name = &input.ident;
    let core = rango_core_path();

    Ok(quote! {
        impl #core::ModelMixin for #name {
            fn mixin_name() -> &'static str {
                stringify!(#name)
            }
        }
    })
}