convert to tabs
This commit is contained in:
parent
faca9fb6a8
commit
e2c681b511
36
src/lib.rs
36
src/lib.rs
@ -6,25 +6,25 @@ use syn::{parse_macro_input, DeriveInput};
|
|||||||
|
|
||||||
#[proc_macro_derive(Id)]
|
#[proc_macro_derive(Id)]
|
||||||
pub fn id_derive(input: TokenStream) -> TokenStream {
|
pub fn id_derive(input: TokenStream) -> TokenStream {
|
||||||
// Parse the input tokens into a syntax tree
|
// Parse the input tokens into a syntax tree
|
||||||
let ast = parse_macro_input!(input as DeriveInput);
|
let ast = parse_macro_input!(input as DeriveInput);
|
||||||
let name = &ast.ident;
|
let name = &ast.ident;
|
||||||
|
|
||||||
// Generate the code for the implementation
|
// Generate the code for the implementation
|
||||||
let expanded = quote! {
|
let expanded = quote! {
|
||||||
impl #name {
|
impl #name {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn new(id: u32) -> Self {
|
pub const fn new(id: u32) -> Self {
|
||||||
Self(id)
|
Self(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub const fn get(self) -> u32 {
|
pub const fn get(self) -> u32 {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Convert the generated code into a token stream and return it
|
// Convert the generated code into a token stream and return it
|
||||||
TokenStream::from(expanded)
|
TokenStream::from(expanded)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user