Attribute Macro pokeapi_macro::pokeapi_struct [−][src]
#[pokeapi_struct]Expand description
Attribute macro to generate a PokéAPI struct.
Panics
Panics if the passed item is not a valid struct.
Examples
ⓘ
// Consider the following example:
use pokeapi_macro::pokeapi_struct;
use std::marker::PhantomData;
#[pokeapi_struct]
struct NamedAPIResource<T> {
description: String,
url: String,
#[serde(skip)]
_resource_type: PhantomData<*const T>,
}
// This attribute will output the `struct` with required derived traits and
// visibility:
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
pub struct NamedAPIResource<T> {
pub description: String,
pub url: String,
#[serde(skip)]
_resource_type: PhantomData<*const T>
}