7 releases (stable)

1.1.4 Mar 26, 2022
1.1.1 Oct 19, 2021
1.0.1 Oct 18, 2021
0.1.0 Oct 18, 2021

#3 in #consider

23 downloads per month
Used in pokeapi-model

MIT/Apache

7KB
78 lines

pokeapi-macro

Attribute macro for pokeapi-model.

Usage

Consider the following example:

use pokeapi_macro::pokeapi_struct;

#[pokeapi_struct]
struct NamedAPIResource<T> {
    description: String,
    url: String,
    _resource_type: std::marker::PhantomData<*const T>,
}

This attribute will output the struct with required derived traits and visibility:

#[derive(Debug, Clone, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)]
pub struct NamedAPIResource<T> {
    pub description: String,
    pub url: String,
    #[serde(skip)]
    _resource_type: std::marker::PhantomData<*const T>
}

Dependencies

~1.5MB
~34K SLoC