use borsh::{BorshDeserialize, BorshSerialize}; #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug)] struct A { x: Vec, y: String, b: B, c: std::result::Result, d: [u64; 5], } #[derive(BorshSerialize, BorshDeserialize, PartialEq, Debug)] enum B { X { f: Vec }, Y(G), } #[test] fn test_generic_struct() { let a = A:: { x: vec!["foo".to_string(), "bar".to_string()], y: "world".to_string(), b: B::X { f: vec![1, 2] }, c: Err("error".to_string()), d: [0, 1, 2, 3, 4], }; let data = a.try_to_vec().unwrap(); let actual_a = A::::try_from_slice(&data).unwrap(); assert_eq!(a, actual_a); }