mokuya 0.0.4

Generic procedural macro helpers for parsing, type analysis, and derive macro generation.
Documentation
1
2
3
4
5
6
7
8
use syn::{Data, DeriveInput, Fields};

pub fn get_fields(input: &DeriveInput) -> Result<&Fields, &str> {
    match &input.data {
        Data::Struct(data_struct) => Ok(&data_struct.fields),
        _ => Err("from_json can only be derived for structs"),
    }
}