From 62725a76ef4f567c16d569fb5da5ffcc0481cb2a Mon Sep 17 00:00:00 2001
From: Nikolai Vazquez <nikvzqz@gmail.com>
Date: Fri, 29 Nov 2019 20:52:26 -0500
Subject: Add `From` impls for `Length`, `Point`, and `Size`

---
 core/src/length.rs |  6 ++++++
 core/src/point.rs  | 12 ++++++++++++
 native/src/size.rs | 12 ++++++++++++
 3 files changed, 30 insertions(+)

diff --git a/core/src/length.rs b/core/src/length.rs
index 63ba6207..10873e89 100644
--- a/core/src/length.rs
+++ b/core/src/length.rs
@@ -27,3 +27,9 @@ impl Length {
         }
     }
 }
+
+impl From<u16> for Length {
+    fn from(units: u16) -> Self {
+        Length::Units(units)
+    }
+}
diff --git a/core/src/point.rs b/core/src/point.rs
index 183998dd..47c8b142 100644
--- a/core/src/point.rs
+++ b/core/src/point.rs
@@ -19,6 +19,18 @@ impl Point {
     }
 }
 
+impl From<[f32; 2]> for Point {
+    fn from([x, y]: [f32; 2]) -> Self {
+        Point { x, y }
+    }
+}
+
+impl From<[u16; 2]> for Point {
+    fn from([x, y]: [u16; 2]) -> Self {
+        Point::new(x.into(), y.into())
+    }
+}
+
 impl std::ops::Add<Vector> for Point {
     type Output = Self;
 
diff --git a/native/src/size.rs b/native/src/size.rs
index 30e2a57e..389b3247 100644
--- a/native/src/size.rs
+++ b/native/src/size.rs
@@ -37,3 +37,15 @@ impl Size {
         }
     }
 }
+
+impl From<[f32; 2]> for Size {
+    fn from([width, height]: [f32; 2]) -> Self {
+        Size { width, height }
+    }
+}
+
+impl From<[u16; 2]> for Size {
+    fn from([width, height]: [u16; 2]) -> Self {
+        Size::new(width.into(), height.into())
+    }
+}
-- 
cgit