1 use darling::{FromDeriveInput, FromMeta};
2 use syn::parse_quote;
3 
4 #[derive(Debug, FromMeta, PartialEq, Eq)]
5 enum Dolor {
6     Sit,
7     #[darling(word)]
8     Amet,
9 }
10 
11 impl Default for Dolor {
default() -> Self12     fn default() -> Self {
13         Dolor::Sit
14     }
15 }
16 
17 #[derive(FromDeriveInput)]
18 #[darling(attributes(hello))]
19 struct Receiver {
20     #[darling(default)]
21     example: Dolor,
22 }
23 
24 #[test]
missing_meta()25 fn missing_meta() {
26     let di = Receiver::from_derive_input(&parse_quote! {
27         #[hello]
28         struct Example;
29     })
30     .unwrap();
31 
32     assert_eq!(Dolor::Sit, di.example);
33 }
34 
35 #[test]
empty_meta()36 fn empty_meta() {
37     let di = Receiver::from_derive_input(&parse_quote! {
38         #[hello(example)]
39         struct Example;
40     })
41     .unwrap();
42 
43     assert_eq!(Dolor::Amet, di.example);
44 }
45