diff -r 99ad55974e62 -r d5b0e496b72f src/sets/cube.rs --- a/src/sets/cube.rs Mon Dec 30 15:46:28 2024 -0500 +++ b/src/sets/cube.rs Mon Jan 06 20:29:25 2025 -0500 @@ -16,7 +16,7 @@ ``` */ -use serde::ser::{Serialize, Serializer, SerializeTupleStruct}; +use serde::{Serialize, Deserialize}; use crate::types::*; use crate::loc::Loc; use crate::sets::SetOrd; @@ -30,25 +30,14 @@ /// A multi-dimensional cube $∏_{i=1}^N [a_i, b_i)$ with the starting and ending points /// along $a_i$ and $b_i$ along each dimension of type `U`. -#[derive(Copy, Clone, Debug, Eq, PartialEq)] -pub struct Cube(pub(super) [[U; 2]; N]); - -// Need to manually implement as [F; N] serialisation is provided only for some N. -impl Serialize for Cube -where - F: Serialize, -{ - fn serialize(&self, serializer: S) -> Result - where - S: Serializer, - { - let mut ts = serializer.serialize_tuple_struct("Cube", N)?; - for e in self.0.iter() { - ts.serialize_field(e)?; - } - ts.end() - } -} +#[derive(Copy, Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] +#[serde(bound( + serialize = "[[U; 2]; N] : Serialize", + deserialize = "[[U; 2]; N] : for<'a> Deserialize<'a>", +))] +pub struct Cube( + pub(super) [[U; 2]; N] +); impl FixedLength for Cube { type Iter = std::array::IntoIter<[A; 2], N>;