Skip to content

Commit

Permalink
Implement std::fmt::Display for all vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciubix8513 committed Aug 3, 2024
1 parent e41691d commit 78b15c3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/math/vec2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,9 @@ impl From<f32> for Vec2 {
Self { x: value, y: value }
}
}

impl std::fmt::Display for Vec2 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({}, {})", self.x, self.y)
}
}
6 changes: 6 additions & 0 deletions src/math/vec3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,9 @@ impl From<f32> for Vec3 {
}
}
}

impl std::fmt::Display for Vec3 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({}, {}, {})", self.x, self.y, self.z)
}
}
6 changes: 6 additions & 0 deletions src/math/vec4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,9 @@ impl From<f32> for Vec4 {
}
}
}

impl std::fmt::Display for Vec4 {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "({}, {}, {}, {})", self.x, self.y, self.z, self.w)
}
}

0 comments on commit 78b15c3

Please sign in to comment.