From 5c0e773242f1c971fefe5e6be8232b5b6d4cf200 Mon Sep 17 00:00:00 2001 From: Benjamin Saunders Date: Mon, 13 Mar 2023 22:45:27 -0700 Subject: [PATCH] Serialize statically sized matrices as tuples Breaking change. Consistent with how serde serializes plain arrays. --- src/base/array_storage.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index 5c165399..dbc5e1d5 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -5,7 +5,7 @@ use std::ops::Mul; #[cfg(feature = "serde-serialize-no-std")] use serde::de::{Error, SeqAccess, Visitor}; #[cfg(feature = "serde-serialize-no-std")] -use serde::ser::SerializeSeq; +use serde::ser::SerializeTuple; #[cfg(feature = "serde-serialize-no-std")] use serde::{Deserialize, Deserializer, Serialize, Serializer}; #[cfg(feature = "serde-serialize-no-std")] @@ -189,7 +189,7 @@ where where S: Serializer, { - let mut serializer = serializer.serialize_seq(Some(R * C))?; + let mut serializer = serializer.serialize_tuple(R * C)?; for e in self.as_slice().iter() { serializer.serialize_element(e)?; @@ -208,7 +208,7 @@ where where D: Deserializer<'a>, { - deserializer.deserialize_seq(ArrayStorageVisitor::new()) + deserializer.deserialize_tuple(R * C, ArrayStorageVisitor::new()) } }