Skip to content

Commit 36b2d7f

Browse files
committed
Implement Default trait for vectors, matrix, points and rect
1 parent f0685a7 commit 36b2d7f

File tree

8 files changed

+48
-0
lines changed

8 files changed

+48
-0
lines changed

graphene/src/box_.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ impl Box {
7979
}
8080
}
8181

82+
impl Default for Box {
83+
fn default() -> Self {
84+
Self::zero()
85+
}
86+
}
87+
8288
impl fmt::Debug for Box {
8389
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
8490
f.debug_struct("Box")

graphene/src/matrix.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,12 @@ impl fmt::Debug for Matrix {
213213
}
214214
}
215215

216+
impl Default for Matrix {
217+
fn default() -> Self {
218+
Self::new_identity()
219+
}
220+
}
221+
216222
#[cfg(test)]
217223
mod tests {
218224
use super::Matrix;

graphene/src/point.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,9 @@ impl fmt::Debug for Point {
5757
.finish()
5858
}
5959
}
60+
61+
impl Default for Point {
62+
fn default() -> Self {
63+
Self::zero()
64+
}
65+
}

graphene/src/point3_d.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,9 @@ impl fmt::Debug for Point3D {
6868
.finish()
6969
}
7070
}
71+
72+
impl Default for Point3D {
73+
fn default() -> Self {
74+
Self::zero()
75+
}
76+
}

graphene/src/rect.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@ impl fmt::Debug for Rect {
3939
}
4040
}
4141

42+
impl Default for Rect {
43+
fn default() -> Self {
44+
Self::zero()
45+
}
46+
}
47+
4248
#[cfg(test)]
4349
mod tests {
4450
use super::*;

graphene/src/vec2.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,9 @@ impl fmt::Debug for Vec2 {
4646
.finish()
4747
}
4848
}
49+
50+
impl Default for Vec2 {
51+
fn default() -> Self {
52+
Self::zero()
53+
}
54+
}

graphene/src/vec3.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ impl fmt::Debug for Vec3 {
4747
.finish()
4848
}
4949
}
50+
51+
impl Default for Vec3 {
52+
fn default() -> Self {
53+
Self::zero()
54+
}
55+
}

graphene/src/vec4.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,9 @@ impl fmt::Debug for Vec4 {
7070
.finish()
7171
}
7272
}
73+
74+
impl Default for Vec4 {
75+
fn default() -> Self {
76+
Self::zero()
77+
}
78+
}

0 commit comments

Comments
 (0)