From 09ef7db9454307723b661fb851a3d3f34d52bb18 Mon Sep 17 00:00:00 2001 From: Techcable Date: Tue, 22 Sep 2026 10:22:26 -0700 Subject: [PATCH 1/2] Remove README references to deprecated Attribute trait Use FromAttr instead. --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index f1cf1fe..1c6029c 100644 --- a/README.md +++ b/README.md @@ -7,10 +7,10 @@ Basically clap for attribute macros: ```rust -use attribute_derive::Attribute; +use attribute_derive::FromAttr; use syn::Type; -#[derive(Attribute)] +#[derive(FromAttr)] #[attribute(ident = collection)] #[attribute(error(missing_field = "`{field}` was not specified"))] struct CollectionAttribute { @@ -42,18 +42,18 @@ There are some limitations in syntax parsing that will be lifted future releases ## Parse methods -There are multiple ways of parsing a struct deriving [`Attribute`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.Attribute.html). +There are multiple ways of parsing a struct deriving [`FromAttr`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.FromAttr.html). For helper attributes there is: -- [`Attribute::from_attributes`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.Attribute.html#tymethod.from_attributes) which takes in an [`IntoIterator`](https://docs.rs/syn/latest/syn/struct.Attribute.html)). Most useful for derive macros. -- [`Attribute::remove_attributes`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.Attribute.html#tymethod.remove_attributes) which takes an [`&mut Vec`](https://docs.rs/syn/latest/syn/struct.Attribute.html) -and does not only parse the [`Attribute`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.Attribute.html#tymethod.from_attributes) but also removes those matching. Useful for helper +- [`FromAttr::remove_attributes`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.FromAttr.html#tymethod.remove_attributes) which takes an [`&mut Vec`](https://docs.rs/syn/latest/syn/struct.Attribute.html) +and does not only parse the [`FromAttr`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.FromAttr.html#tymethod.from_attributes) but also removes those matching. Useful for helper attributes for proc macros, where the helper attributes need to be removed. For parsing a single [`TokenStream`](https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html) e.g. for parsing the proc macro input there a two ways: -- [`Attribute::from_args`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.Attribute.html#tymethod.from_args) taking in a [`TokenStream`](https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html) -- As `derive(Attribute)` also derives [`Parse`](https://docs.rs/syn/latest/syn/parse/trait.Parse.html) so you can use the [parse](https://docs.rs/syn/latest/syn/parse/index.html) API, +- [`FromAttr::from_args`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.FromAttr.html#tymethod.from_args) taking in a [`TokenStream`](https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html) +- As `derive(FromAttr)` also derives [`Parse`](https://docs.rs/syn/latest/syn/parse/trait.Parse.html) so you can use the [parse](https://docs.rs/syn/latest/syn/parse/index.html) API, e.g. with [`parse_macro_input!(tokens as Attribute)`](https://docs.rs/syn/latest/syn/macro.parse_macro_input.html). From 786003f2283376e7270e1d4ba17e16dd94b83807 Mon Sep 17 00:00:00 2001 From: Techcable Date: Tue, 22 Sep 2026 10:10:45 -0700 Subject: [PATCH 2/2] Remove doc references to FromAttr::from_args This is deprecated in favor of FromAttr::from_input. --- README.md | 2 +- src/lib.rs | 6 +++--- src/utils.rs | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 1c6029c..89bbdef 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,6 @@ attributes for proc macros, where the helper attributes need to be removed. For parsing a single [`TokenStream`](https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html) e.g. for parsing the proc macro input there a two ways: -- [`FromAttr::from_args`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.FromAttr.html#tymethod.from_args) taking in a [`TokenStream`](https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html) +- [`FromAttr::from_input`](https://docs.rs/attribute-derive/latest/attribute_derive/trait.FromAttr.html#tymethod.from_input) taking in a [`TokenStream`](https://docs.rs/proc-macro2/latest/proc_macro2/struct.TokenStream.html) - As `derive(FromAttr)` also derives [`Parse`](https://docs.rs/syn/latest/syn/parse/trait.Parse.html) so you can use the [parse](https://docs.rs/syn/latest/syn/parse/index.html) API, e.g. with [`parse_macro_input!(tokens as Attribute)`](https://docs.rs/syn/latest/syn/macro.parse_macro_input.html). diff --git a/src/lib.rs b/src/lib.rs index 2e06cc9..b8ac31d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,7 @@ //! use syn::{Attribute, parse_quote}; //! use attribute_derive::FromAttr; //! -//! #[derive(FromAttr, PartialEq, Debug)] +//! #[derive(FromAttr, PartialEq, Debug)] //! #[attribute(ident = flag)] //! struct Flag(bool); //! @@ -138,7 +138,7 @@ //! For parsing a single [`TokenStream`] e.g. for parsing the proc macro input //! there are two ways: //! -//! - [`FromAttr::from_args`] taking in a [`TokenStream`] +//! - [`FromAttr::from_input`] taking in a [`TokenStream`] //! - As `derive(FromAttr)` also derives [`Parse`] so you can use the //! [parse](mod@syn::parse) API, e.g. with [`parse_macro_input!(tokens as //! Attribute)`](syn::parse_macro_input!). @@ -318,7 +318,7 @@ mod tmp { } /// Parses from a single attribute. Ignoring the name. - /// + /// /// This is available even without `#[attribute(ident = ...)]`, because /// it ignores the attribute's path, allowing to use it to parse e.g. /// literals: diff --git a/src/utils.rs b/src/utils.rs index e2ef618..bead83e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -23,20 +23,20 @@ use crate::{SpannedValue, *}; /// } /// /// assert_eq!( -/// Test::from_args(quote!(param)).unwrap().param, +/// Test::from_input(quote!(param)).unwrap().param, /// FlagOrValue::Flag /// ); /// assert_eq!( -/// Test::from_args(quote!(param = "value")).unwrap().param, +/// Test::from_input(quote!(param = "value")).unwrap().param, /// FlagOrValue::Value("value".into()) /// ); /// assert_eq!( -/// Test::from_args(quote!(param, param = "value", param)) +/// Test::from_input(quote!(param, param = "value", param)) /// .unwrap() /// .param, /// FlagOrValue::Value("value".into()) /// ); -/// assert_eq!(Test::from_args(quote!()).unwrap().param, FlagOrValue::None); +/// assert_eq!(Test::from_input(quote!()).unwrap().param, FlagOrValue::None); /// ``` #[derive(Debug, Default, PartialEq, Eq, PartialOrd, Ord)] pub enum FlagOrValue {