Skip to content

Commit 34ba680

Browse files
committed
fix tests
1 parent e779a39 commit 34ba680

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
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)]

tests/derive.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
}

0 commit comments

Comments
 (0)