mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-25 08:07:56 +00:00
36 lines
874 B
Rust
36 lines
874 B
Rust
extern crate proc_macro;
|
|
extern crate proc_macro2;
|
|
extern crate quote;
|
|
extern crate syn;
|
|
|
|
#[macro_use]
|
|
mod bound;
|
|
#[macro_use]
|
|
mod fragment;
|
|
|
|
mod de;
|
|
mod dummy;
|
|
mod internals;
|
|
mod pretend;
|
|
mod ser;
|
|
mod this;
|
|
|
|
use proc_macro::TokenStream;
|
|
use syn::{parse_macro_input, DeriveInput};
|
|
|
|
#[proc_macro_derive(Serialize, attributes(serde))]
|
|
pub fn derive_serialize(input: TokenStream) -> TokenStream {
|
|
let mut input = parse_macro_input!(input as DeriveInput);
|
|
ser::expand_derive_serialize(&mut input)
|
|
.unwrap_or_else(syn::Error::into_compile_error)
|
|
.into()
|
|
}
|
|
|
|
#[proc_macro_derive(Deserialize, attributes(serde))]
|
|
pub fn derive_deserialize(input: TokenStream) -> TokenStream {
|
|
let mut input = parse_macro_input!(input as DeriveInput);
|
|
de::expand_derive_deserialize(&mut input)
|
|
.unwrap_or_else(syn::Error::into_compile_error)
|
|
.into()
|
|
}
|