From b192b562b49e0de2ff9cbc20a3dd995ad615f78d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 24 May 2018 07:25:15 -0700 Subject: Support fixed-length arrays Turns out these are deserialized/serialized as tuples! While we're at it add support for tuple variants and tuple structs through the same paths. Closes #244 --- test-suite/tests/serde.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'test-suite') diff --git a/test-suite/tests/serde.rs b/test-suite/tests/serde.rs index 57fa5db..446cd7a 100644 --- a/test-suite/tests/serde.rs +++ b/test-suite/tests/serde.rs @@ -569,10 +569,23 @@ fn table_structs_empty() { expected.insert("bar".to_string(), CanBeEmpty::default()); expected.insert("baz".to_string(), CanBeEmpty::default()); expected.insert( - "bazv".to_string(), + "bazv".to_string(), CanBeEmpty {a: Some("foo".to_string()), b: None}, ); expected.insert("foo".to_string(), CanBeEmpty::default()); assert_eq!(value, expected); assert_eq!(toml::to_string(&value).unwrap(), text); } + +#[test] +fn fixed_size_array() { + #[derive(Serialize, PartialEq, Eq, Deserialize, Debug)] + struct Entity { + pos: [i32; 2] + } + let text = "pos = [1, 2]\n"; + let value: Entity = toml::from_str(text).unwrap(); + let expected = Entity { pos: [1, 2] }; + assert_eq!(value, expected); + assert_eq!(toml::to_string(&value).unwrap(), text); +} -- cgit v1.2.3