Merge pull request #585 from fusion-engineering-forks/pr-default

This commit is contained in:
Sébastien Crozet 2020-06-07 08:58:47 +02:00 committed by GitHub
commit 423b4b27b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 42 additions and 0 deletions

View File

@ -48,6 +48,19 @@ where
/// Renamed to [ArrayStorage].
pub type MatrixArray<N, R, C> = ArrayStorage<N, R, C>;
impl<N, R, C> Default for ArrayStorage<N, R, C>
where
R: DimName,
C: DimName,
R::Value: Mul<C::Value>,
Prod<R::Value, C::Value>: ArrayLength<N>,
N: Default,
{
fn default() -> Self {
ArrayStorage { data: Default::default() }
}
}
impl<N, R, C> Hash for ArrayStorage<N, R, C>
where
N: Hash,

View File

@ -94,6 +94,21 @@ impl<N: Scalar, R: Dim, C: Dim, S: fmt::Debug> fmt::Debug for Matrix<N, R, C, S>
}
}
impl<N, R, C, S> Default for Matrix<N, R, C, S>
where
N: Scalar,
R: Dim,
C: Dim,
S: Default,
{
fn default() -> Self {
Matrix {
data: Default::default(),
_phantoms: PhantomData,
}
}
}
#[cfg(feature = "serde-serialize")]
impl<N, R, C, S> Serialize for Matrix<N, R, C, S>
where

View File

@ -33,6 +33,14 @@ pub struct Quaternion<N: Scalar + SimdValue> {
pub coords: Vector4<N>,
}
impl<N: RealField> Default for Quaternion<N> {
fn default() -> Self {
Quaternion {
coords: Vector4::zeros()
}
}
}
#[cfg(feature = "abomonation-serialize")]
impl<N: SimdRealField> Abomonation for Quaternion<N>
where
@ -1536,6 +1544,12 @@ where
}
}
impl<N: RealField> Default for UnitQuaternion<N> {
fn default() -> Self {
Self::identity()
}
}
impl<N: RealField + fmt::Display> fmt::Display for UnitQuaternion<N> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(axis) = self.axis() {