#![cfg(test)] #![allow(dead_code, unused_variables)] use nestify::nest; #[test] fn es() {} #[test] fn please_work() { let s = 32; nest!( struct Hello { pub o: struct Another { s: struct A { a: struct B { asdfs: struct BB { }, }, c: i32, d: struct D();, asd: Option, }, }, pub unmaed: struct Unamed;, } ); } #[test] fn enum_test() { nest! { enum Outside { Empty, Tuple(Option, i32, enum Nested1 { }), #>[derive(Debug)]* Named { a: (), b: Option, c: enum Nested2 { Tuple2(enum Nested3 {}) }, d: struct Another {} } } } } #[test] fn attribute_test() { nest! { #[derive(Default)] enum AnEnum { #[default] One = 1, Default, Two, } } // nest! { // struct Outside { // f : struct Inside { // gf: G // }, // } // } let v = vec![1, 2, 3]; let v2 = v.into_iter().collect::>(); nest! { struct A(T) where T: Clone } } #[test] fn test_semis() { // nest! { // struct Two(:: struct One(T)) // } nest! { struct Outside ( enum E {Se(T)} ||, ) } } struct One1 (T) ; struct Two1( One1) ; #[derive(Default)] enum AnEnum { One = 1, #[default] Default, Two, } struct NeedsLife<'a> { string: &'a str } #[test] fn test_fish_errors() { nest! { struct Base( struct NoError { tf: T } ||) } } #[test] fn augmented_types() { { nest! { struct Foo { field: Option, } }; let foo = Foo { field: Some(Bar { foo: 42 })}; } { nest! { struct Foo( Option, ) }; let foo = Foo (Some(Bar { foo: 42 })); } { nest! { enum Foo { Variant { field: Option<#[derive(Debug)] struct Bar { foo: u32 }>, } } }; let foo = Foo::Variant { field: Some(Bar { foo: 42 })}; } { nest! { #[derive(Debug)]* enum Foo { Variant( Option, ) } }; let foo = Foo::Variant (Some(Bar { foo: 42 })); println!("{foo:?}"); } { nest! { struct Foo { field: Option(T) ||>, } }; let foo = Foo { field: Some(Bar(42)) }; // check it is actually a generic struct let bar: Bar = Bar("test".to_string()); } }