/// Test ensuring derivation works for types with type parameters. use concordium_std::*; #[derive(Serial)] struct MyStruct { field: A, other_field: u8, } #[derive(Serial)] struct MyOtherStruct { field: A, other_field: B, } #[derive(Serial)] enum MyEnum { One(u32), Two(A), } #[derive(Serial)] enum MyOtherEnum { One(u32), Two(A, B), } #[derive(Serial)] #[concordium(state_parameter = "S")] struct WithStateParameter { test_map: StateMap, } #[derive(Serial)] #[concordium(state_parameter = "S")] struct WithStateParameterWhere where S: HasStateApi, S: Clone, { test_map: StateMap, } #[rustfmt::skip] // skip formatting to maintain lack of trailing comma mod inner { use super::*; #[derive(Serial)] #[concordium(state_parameter = "S")] struct WithStateParameterWhereTwo where S: HasStateApi, S: Clone { // note the lack of comma compared to the test above test_map: StateMap, } #[derive(Serial)] #[concordium(state_parameter = "S")] struct WithStateParameterWhereThree where // empty where clause { test_map: StateMap, } } trait ProxyTrait { type State: HasStateApi; } #[derive(Serial)] #[concordium(state_parameter = "T::State")] struct WithAssocStateParameter { test_map: StateMap, } fn main() { { let value = MyStruct:: { field: 42, other_field: 5, }; let _bytes = to_bytes(&value); } { let value = MyOtherStruct:: { field: 42, other_field: 5, }; let _bytes = to_bytes(&value); } { let value = MyEnum::::Two(1); let _bytes = to_bytes(&value); } { let value = MyOtherEnum::::Two(1, 15); let _bytes = to_bytes(&value); } }