summaryrefslogtreecommitdiffstats
path: root/core/src/point.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón <hector0193@gmail.com>2019-11-30 17:01:01 +0100
committerLibravatar GitHub <noreply@github.com>2019-11-30 17:01:01 +0100
commite404f5098a4e053f52e75175b6cd677e60d27517 (patch)
treef9505a4e2bc7f4f0038252caa733ba33a4e147cc /core/src/point.rs
parent811d8b90d71c26100f0933217f5474e090fbf17c (diff)
parent62725a76ef4f567c16d569fb5da5ffcc0481cb2a (diff)
downloadiced-e404f5098a4e053f52e75175b6cd677e60d27517.tar.gz
iced-e404f5098a4e053f52e75175b6cd677e60d27517.tar.bz2
iced-e404f5098a4e053f52e75175b6cd677e60d27517.zip
Merge pull request #92 from nvzqz/type-conversions
Add `From` impls for `Length`, `Point`, and `Size`
Diffstat (limited to 'core/src/point.rs')
-rw-r--r--core/src/point.rs12
1 files changed, 12 insertions, 0 deletions
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;