Skip to content

Commit

Permalink
Add a from Dir2 impl for Vec2 (bevyengine#12594)
Browse files Browse the repository at this point in the history
# Objective

Allow converting from `Dir2` to `Vec2` in generic code. Fixes bevyengine#12529.

## Solution

Added a `From<Dir2>` impl for `Vec2`.
  • Loading branch information
Brezak authored Mar 20, 2024
1 parent 4d0d070 commit ed44eb3
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/bevy_math/src/direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ impl TryFrom<Vec2> for Dir2 {
}
}

impl From<Dir2> for Vec2 {
fn from(value: Dir2) -> Self {
value.as_vec2()
}
}

impl std::ops::Deref for Dir2 {
type Target = Vec2;
fn deref(&self) -> &Self::Target {
Expand Down

0 comments on commit ed44eb3

Please sign in to comment.