/// Test ensuring derivation works for types with type parameters. use concordium_std::*; #[derive(Deserial)] struct MyStruct { field: A, other_field: u8, } #[derive(Deserial)] struct MyOtherStruct { field: A, other_field: B, } #[derive(Deserial)] enum MyEnum { One(u32), Two(A), } #[derive(Deserial)] enum MyOtherEnum { One(u32), Two(A, B), } #[derive(Deserial)] struct WithStateParameterWhere where S: Clone, S: PartialOrd, { value: S, } #[rustfmt::skip] // skip formatting to maintain lack of trailing comma mod inner { use super::*; #[derive(Deserial)] struct WithStateParameterWhereTwo where S: Clone, // note the lack of comma compared to the test above S: PartialOrd { value: S, } #[derive(Deserial)] struct WithStateParameterWhereThree where // empty where clause { value: S, } } #[derive(Deserial)] #[concordium(bound(deserial = ""))] struct ExplicitBound { field: marker::PhantomData, } struct NotImplemtingDeserial; fn main() { { let bytes = [0u8; 9]; let _value: MyStruct = from_bytes(&bytes).expect("Deserialize MyStruct"); } { let bytes = [0u8; 9]; let _value: MyOtherStruct = from_bytes(&bytes).expect("Deserialize MyOtherStruct"); } { let bytes = [1u8; 9]; let _value: MyEnum = from_bytes(&bytes).expect("Deserialize MyOtherStruct"); } { let bytes = [1u8; 10]; let _value: MyOtherEnum = from_bytes(&bytes).expect("Deserialize MyOtherStruct"); } { let bytes = [0u8; 0]; let _value: ExplicitBound = from_bytes(&bytes).expect("Deserialize ExplicitBound"); } }