Fix serde impls and Distribution impl for OPoint

This commit is contained in:
Andreas Longva 2021-07-02 12:01:01 +02:00
parent 16b8f4812d
commit 92c26334ec
2 changed files with 4 additions and 2 deletions

View File

@ -85,6 +85,7 @@ where
impl<T: Scalar + Serialize, D: DimName> Serialize for OPoint<T, D> impl<T: Scalar + Serialize, D: DimName> Serialize for OPoint<T, D>
where where
DefaultAllocator: Allocator<T, D>, DefaultAllocator: Allocator<T, D>,
<DefaultAllocator as Allocator<T, D>>::Buffer: Serialize
{ {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where where
@ -98,12 +99,13 @@ where
impl<'a, T: Scalar + Deserialize<'a>, D: DimName> Deserialize<'a> for OPoint<T, D> impl<'a, T: Scalar + Deserialize<'a>, D: DimName> Deserialize<'a> for OPoint<T, D>
where where
DefaultAllocator: Allocator<T, D>, DefaultAllocator: Allocator<T, D>,
<DefaultAllocator as Allocator<T, D>>::Buffer: Deserialize<'a>
{ {
fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error> fn deserialize<Des>(deserializer: Des) -> Result<Self, Des::Error>
where where
Des: Deserializer<'a>, Des: Deserializer<'a>,
{ {
let coords = SVector::<T, D>::deserialize(deserializer)?; let coords = OVector::<T, D>::deserialize(deserializer)?;
Ok(Self::from(coords)) Ok(Self::from(coords))
} }

View File

@ -168,7 +168,7 @@ where
/// Generate a `Point` where each coordinate is an independent variate from `[0, 1)`. /// Generate a `Point` where each coordinate is an independent variate from `[0, 1)`.
#[inline] #[inline]
fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> OPoint<T, D> { fn sample<'a, G: Rng + ?Sized>(&self, rng: &mut G) -> OPoint<T, D> {
Point::from(rng.gen::<OVector<T, D>>()) OPoint::from(rng.gen::<OVector<T, D>>())
} }
} }