@@ -80,6 +80,15 @@ use syn::Variant;
8080/// #[derive(BFieldCodec)] // Currently not supported.
8181/// enum Foo {} // Consider `struct Foo;` instead.
8282/// ```
83+ ///
84+ /// - Ignoring fields in tuple structs is currently not supported. Consider
85+ /// using a struct with named fields instead. Example:
86+ /// ```ignore
87+ /// #[derive(BFieldCodec)]
88+ /// struct Foo(#[bfield_codec(ignore)] u32);
89+ /// // ~~~~~~~~~~~~~~~~~~~~~~~
90+ /// // Currently not supported in tuple structs
91+ /// ```
8392#[ proc_macro_derive( BFieldCodec , attributes( bfield_codec) ) ]
8493pub fn bfieldcodec_derive ( input : proc_macro:: TokenStream ) -> proc_macro:: TokenStream {
8594 let ast = parse_macro_input ! ( input as DeriveInput ) ;
@@ -210,11 +219,14 @@ impl BFieldCodecDeriveBuilder {
210219 . attrs
211220 . iter ( )
212221 . filter ( |attr| attr. path ( ) . is_ident ( "bfield_codec" ) ) ;
213- let attribute = match relevant_attributes. clone ( ) . count ( ) {
214- 0 => return false ,
215- 1 => relevant_attributes. next ( ) . unwrap ( ) ,
216- _ => panic ! ( "field `{field_name}` must have at most 1 `bfield_codec` attribute" ) ,
222+
223+ let Some ( attribute) = relevant_attributes. next ( ) else {
224+ return false ;
217225 } ;
226+ if relevant_attributes. next ( ) . is_some ( ) {
227+ panic ! ( "field `{field_name}` must have at most 1 `bfield_codec` attribute" ) ;
228+ }
229+
218230 let parse_ignore = attribute. parse_nested_meta ( |meta| match meta. path . get_ident ( ) {
219231 Some ( ident) if ident == "ignore" => Ok ( ( ) ) ,
220232 Some ( ident) => panic ! ( "unknown identifier `{ident}` for field `{field_name}`" ) ,
0 commit comments