File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change 4949//! will copy the behavior of the contained field, e.g. for [`bool`]:
5050//!
5151//! ```
52+ //! use syn::{Attribute, parse_quote};
5253//! use attribute_derive::FromAttr;
5354//!
5455//! #[derive(FromAttr, PartialEq, Debug)]
Original file line number Diff line number Diff line change @@ -256,3 +256,18 @@ fn tuple() {
256256 Multiple ( true , "value" . into( ) )
257257 ) ;
258258}
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