Initial Implementation of ResourceGuard Macro
This commit is contained in:
13
proc-utils/Cargo.toml
Normal file
13
proc-utils/Cargo.toml
Normal file
@@ -0,0 +1,13 @@
|
||||
[package]
|
||||
name = "proc-utils"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[lib]
|
||||
proc-macro = true
|
||||
|
||||
[dependencies]
|
||||
syn = "2.0.50"
|
||||
quote = "1.0.35"
|
||||
11
proc-utils/src/lib.rs
Normal file
11
proc-utils/src/lib.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use proc_macro::TokenStream;
|
||||
use quote::quote;
|
||||
use syn::{parse_macro_input, ItemFn};
|
||||
|
||||
#[proc_macro_attribute]
|
||||
pub fn guard_resource(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
let input = parse_macro_input!(item as ItemFn);
|
||||
println!("{} defined", input.sig.ident);
|
||||
println!("Args received: {}", _attr.to_string());
|
||||
return TokenStream::from(quote!(#input));
|
||||
}
|
||||
Reference in New Issue
Block a user