Skip to content

Commit

Permalink
Update example in README which used the outdated AttributeArgs type
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasbb authored and TedDriggs committed Apr 27, 2023
1 parent c036162 commit cbb7389
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ This will produce a normal `darling::Result<T>` that can be used the same as a r
## Macro Code

```rust,ignore
use darling::FromMeta;
use syn::{AttributeArgs, ItemFn};
use darling::{Error, FromMeta};
use darling::ast::NestedMeta;
use syn::ItemFn;
use proc_macro::TokenStream;
#[derive(Debug, FromMeta)]
Expand All @@ -80,10 +81,13 @@ pub struct MacroArgs {
path: String,
}
#[proc_macro_attribute]
// #[proc_macro_attribute]
fn your_attr(args: TokenStream, input: TokenStream) -> TokenStream {
let attr_args = parse_macro_input!(args as AttributeArgs);
let _input = parse_macro_input!(input as ItemFn);
let attr_args = match NestedMeta::parse_meta_list(args) {
Ok(v) => v,
Err(e) => { return TokenStream::from(Error::from(e).write_errors()); }
};
let _input = syn::parse_macro_input!(input as ItemFn);
let _args = match MacroArgs::from_list(&attr_args) {
Ok(v) => v,
Expand Down

0 comments on commit cbb7389

Please sign in to comment.