Implement Default for MatrixMN.

This commit is contained in:
Mara Bos 2019-04-16 10:11:27 +02:00
parent 049957ff55
commit e6265da980
2 changed files with 28 additions and 0 deletions

View File

@ -48,6 +48,19 @@ where
/// Renamed to [ArrayStorage]. /// Renamed to [ArrayStorage].
pub type MatrixArray<N, R, C> = ArrayStorage<N, R, C>; 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> impl<N, R, C> Hash for ArrayStorage<N, R, C>
where where
N: Hash, N: Hash,

View File

@ -90,6 +90,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")] #[cfg(feature = "serde-serialize")]
impl<N, R, C, S> Serialize for Matrix<N, R, C, S> impl<N, R, C, S> Serialize for Matrix<N, R, C, S>
where where