Merge pull request #870 from dimforge/dvector_serialize

Fix serialization of DVector
This commit is contained in:
Sébastien Crozet 2021-04-12 17:52:10 +02:00 committed by GitHub
commit 9e5e8e7b94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -211,6 +211,26 @@ pub trait DimName: Dim {
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 {
type Const: DimName;
}