Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Default trait for vectors #979

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions graphene/src/box_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ impl Box {
}
}

impl Default for Box {
fn default() -> Self {
Self::zero()
}
}

impl fmt::Debug for Box {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Box")
Expand Down
6 changes: 6 additions & 0 deletions graphene/src/matrix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ impl fmt::Debug for Matrix {
}
}

impl Default for Matrix {
fn default() -> Self {
Self::new_identity()
}
}

#[cfg(test)]
mod tests {
use super::Matrix;
Expand Down
6 changes: 6 additions & 0 deletions graphene/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,9 @@ impl fmt::Debug for Point {
.finish()
}
}

impl Default for Point {
fn default() -> Self {
Self::zero()
}
}
6 changes: 6 additions & 0 deletions graphene/src/point3_d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,9 @@ impl fmt::Debug for Point3D {
.finish()
}
}

impl Default for Point3D {
fn default() -> Self {
Self::zero()
}
}
6 changes: 6 additions & 0 deletions graphene/src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ impl fmt::Debug for Rect {
}
}

impl Default for Rect {
fn default() -> Self {
Self::zero()
}
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
6 changes: 6 additions & 0 deletions graphene/src/vec2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ impl fmt::Debug for Vec2 {
.finish()
}
}

impl Default for Vec2 {
fn default() -> Self {
Self::zero()
}
}
6 changes: 6 additions & 0 deletions graphene/src/vec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ impl fmt::Debug for Vec3 {
.finish()
}
}

impl Default for Vec3 {
fn default() -> Self {
Self::zero()
}
}
6 changes: 6 additions & 0 deletions graphene/src/vec4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ impl fmt::Debug for Vec4 {
.finish()
}
}

impl Default for Vec4 {
fn default() -> Self {
Self::zero()
}
}