From e6bcb7211f5e326aac4b584b44d3afff6de595ee Mon Sep 17 00:00:00 2001 From: Azorlogh Date: Thu, 8 Oct 2020 09:54:22 +0200 Subject: [PATCH] add From and From for [f32; 2] --- core/src/point.rs | 6 ++++++ core/src/size.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/core/src/point.rs b/core/src/point.rs index 3714aa2f..7d93538f 100644 --- a/core/src/point.rs +++ b/core/src/point.rs @@ -46,6 +46,12 @@ impl From<[u16; 2]> for Point { } } +impl From for [f32; 2] { + fn from(point: Point) -> [f32; 2] { + [point.x, point.y] + } +} + impl std::ops::Add for Point { type Output = Self; diff --git a/core/src/size.rs b/core/src/size.rs index aceb5311..7c481935 100644 --- a/core/src/size.rs +++ b/core/src/size.rs @@ -56,3 +56,9 @@ impl From<[u16; 2]> for Size { Size::new(width.into(), height.into()) } } + +impl From for [f32; 2] { + fn from(size: Size) -> [f32; 2] { + [size.width, size.height] + } +}