File tree 2 files changed +16
-0
lines changed 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 49
49
//! will copy the behavior of the contained field, e.g. for [`bool`]:
50
50
//!
51
51
//! ```
52
+ //! use syn::{Attribute, parse_quote};
52
53
//! use attribute_derive::FromAttr;
53
54
//!
54
55
//! #[derive(FromAttr, PartialEq, Debug)]
Original file line number Diff line number Diff line change @@ -256,3 +256,18 @@ fn tuple() {
256
256
Multiple ( true , "value" . into( ) )
257
257
) ;
258
258
}
259
+
260
+ #[ test]
261
+ fn attribute_ident_option ( ) {
262
+ #[ derive( FromAttr ) ]
263
+ #[ attribute( ident = test) ]
264
+ struct Test ( String ) ;
265
+
266
+ let attr: Attribute = parse_quote ! ( #[ test( "hello" ) ] ) ;
267
+ assert_eq ! (
268
+ Option :: <Test >:: from_attributes( [ attr] ) . unwrap( ) . unwrap( ) . 0 ,
269
+ "hello"
270
+ ) ;
271
+ let attr: Attribute = parse_quote ! ( #[ not_test( "hello" ) ] ) ;
272
+ assert ! ( Option :: <Test >:: from_attributes( [ attr] ) . unwrap( ) . is_none( ) ) ;
273
+ }
You can’t perform that action at this time.
0 commit comments