Skip to content

Commit

Permalink
Add Default impl for Unit
Browse files Browse the repository at this point in the history
  • Loading branch information
shunkit committed Oct 9, 2024
1 parent 338a22b commit 4e98715
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/base/unit.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
use std::fmt;
use std::ops::Deref;

use num::{One, Zero};

#[cfg(feature = "serde-serialize-no-std")]
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::allocator::Allocator;
use crate::base::DefaultAllocator;
use crate::storage::RawStorage;
use crate::{Dim, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealField};
use crate::{Dim, DimName, Matrix, OMatrix, RealField, Scalar, SimdComplexField, SimdRealField};

#[cfg(feature = "rkyv-serialize")]
use rkyv::bytecheck;
Expand Down Expand Up @@ -71,6 +73,18 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit<T> {
}
}

impl<T, R, C> Default for Unit<OMatrix<T, R, C>>
where
T: Scalar + Zero + One,
R: DimName,
C: DimName,
DefaultAllocator: Allocator<R, C>,
{
fn default() -> Self {
Self::new_unchecked(OMatrix::<T, R, C>::identity())
}
}

impl<T, R, C, S> PartialEq for Unit<Matrix<T, R, C, S>>
where
T: Scalar + PartialEq,
Expand Down

0 comments on commit 4e98715

Please sign in to comment.