summaryrefslogtreecommitdiffstats
path: root/vendor/darling-0.14.4/tests/newtype.rs
blob: 10d02388829632c9e6f4a90ef1763d12d9faf43e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! A newtype struct should be able to derive `FromMeta` if its member implements it.

use darling::{FromDeriveInput, FromMeta};
use syn::parse_quote;

#[derive(Debug, FromMeta, PartialEq, Eq)]
struct Lorem(bool);

#[derive(Debug, FromDeriveInput)]
#[darling(attributes(newtype))]
struct DemoContainer {
    lorem: Lorem,
}

#[test]
fn generated() {
    let di = parse_quote! {
        #[derive(Baz)]
        #[newtype(lorem = false)]
        pub struct Foo;
    };

    let c = DemoContainer::from_derive_input(&di).unwrap();

    assert_eq!(c.lorem, Lorem(false));
}