mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 12:18:33 +00:00
17 lines
446 B
Rust
17 lines
446 B
Rust
extern crate proc_macro;
|
|
|
|
use proc_macro::TokenStream;
|
|
|
|
#[proc_macro_derive(AToB)]
|
|
pub fn derive1(input: TokenStream) -> TokenStream {
|
|
println!("input1: {:?}", input.to_string());
|
|
assert_eq!(input.to_string(), "struct A;");
|
|
"#[derive(BToC)] struct B;".parse().unwrap()
|
|
}
|
|
|
|
#[proc_macro_derive(BToC)]
|
|
pub fn derive2(input: TokenStream) -> TokenStream {
|
|
assert_eq!(input.to_string(), "struct B;");
|
|
"struct C;".parse().unwrap()
|
|
}
|