diff --git a/src/base/unit.rs b/src/base/unit.rs index 84cfc3154..128c4614b 100644 --- a/src/base/unit.rs +++ b/src/base/unit.rs @@ -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; @@ -71,6 +73,18 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Unit { } } +impl Default for Unit> +where + T: Scalar + Zero + One, + R: DimName, + C: DimName, + DefaultAllocator: Allocator, +{ + fn default() -> Self { + Self::new_unchecked(OMatrix::::identity()) + } +} + impl PartialEq for Unit> where T: Scalar + PartialEq,