modi_macros 0.1.1

Code generation for the modi dependency injection framework
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use crate::parser::Parser;
use crate::structures::service::Property;
use syn::{Data, DeriveInput, Error, Field};

impl Parser<Vec<Property>> for DeriveInput {
    fn parse_as(&self) -> syn::Result<Vec<Property>> {
        match &self.data {
            Data::Struct(data) => data.fields.iter().map(Field::parse_as).collect(),
            _ => Err(Error::new(
                self.ident.span(),
                "Only structs are currently supported".to_string(),
            )),
        }
    }
}