Fix serialization of DVector

This commit is contained in:
Crozet Sébastien 2021-04-12 17:43:04 +02:00
parent c5c6c139ab
commit f70e7f77d1
1 changed files with 20 additions and 0 deletions

View File

@ -211,6 +211,26 @@ pub trait DimName: Dim {
fn dim() -> usize; fn dim() -> usize;
} }
#[cfg(feature = "serde-serialize-no-std")]
impl<const D: usize> Serialize for Const<D> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
().serialize(serializer)
}
}
#[cfg(feature = "serde-serialize-no-std")]
impl<'de, const D: usize> Deserialize<'de> for Const<D> {
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
where
Des: Deserializer<'de>,
{
<()>::deserialize(deserializer).map(|_| Const::<D>)
}
}
pub trait ToConst { pub trait ToConst {
type Const: DimName; type Const: DimName;
} }