From e6265da98033c6ebf4e939737b8de2cd4d38cbd6 Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 16 Apr 2019 10:11:27 +0200 Subject: [PATCH] Implement Default for MatrixMN. --- src/base/array_storage.rs | 13 +++++++++++++ src/base/matrix.rs | 15 +++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/base/array_storage.rs b/src/base/array_storage.rs index bebb8740..450127ba 100644 --- a/src/base/array_storage.rs +++ b/src/base/array_storage.rs @@ -48,6 +48,19 @@ where /// Renamed to [ArrayStorage]. pub type MatrixArray = ArrayStorage; +impl Default for ArrayStorage +where + R: DimName, + C: DimName, + R::Value: Mul, + Prod: ArrayLength, + N: Default, +{ + fn default() -> Self { + ArrayStorage { data: Default::default() } + } +} + impl Hash for ArrayStorage where N: Hash, diff --git a/src/base/matrix.rs b/src/base/matrix.rs index 7119a8ad..1aa171e4 100644 --- a/src/base/matrix.rs +++ b/src/base/matrix.rs @@ -90,6 +90,21 @@ impl fmt::Debug for Matrix } } +impl Default for Matrix +where + N: Scalar, + R: Dim, + C: Dim, + S: Default, +{ + fn default() -> Self { + Matrix { + data: Default::default(), + _phantoms: PhantomData, + } + } +} + #[cfg(feature = "serde-serialize")] impl Serialize for Matrix where