Skip to content

Commit

Permalink
add From<Point> and From<Size> for [f32; 2]
Browse files Browse the repository at this point in the history
  • Loading branch information
Azorlogh committed Oct 8, 2020
1 parent 2e0ba65 commit e6bcb72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/point.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ impl From<[u16; 2]> for Point {
}
}

impl From<Point> for [f32; 2] {
fn from(point: Point) -> [f32; 2] {
[point.x, point.y]
}
}

impl std::ops::Add<Vector> for Point {
type Output = Self;

Expand Down
6 changes: 6 additions & 0 deletions core/src/size.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,9 @@ impl From<[u16; 2]> for Size {
Size::new(width.into(), height.into())
}
}

impl From<Size> for [f32; 2] {
fn from(size: Size) -> [f32; 2] {
[size.width, size.height]
}
}

0 comments on commit e6bcb72

Please sign in to comment.