summaryrefslogtreecommitdiffstats
path: root/core/src/point.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-09 06:35:33 +0100
committerLibravatar Héctor Ramón Jiménez <hector@hecrj.dev>2024-01-10 10:01:49 +0100
commitd62bb8193c1c43f565fcc5c52293d564c91e215d (patch)
tree7f2d33d2f18a3dfb4e4e8e46b4e968523ca43bc6 /core/src/point.rs
parentd24e50c1a61eee7bca887224ad583eca60e14d32 (diff)
downloadiced-d62bb8193c1c43f565fcc5c52293d564c91e215d.tar.gz
iced-d62bb8193c1c43f565fcc5c52293d564c91e215d.tar.bz2
iced-d62bb8193c1c43f565fcc5c52293d564c91e215d.zip
Introduce useful helpers in `layout` module
Diffstat (limited to 'core/src/point.rs')
-rw-r--r--core/src/point.rs20
1 files changed, 13 insertions, 7 deletions
diff --git a/core/src/point.rs b/core/src/point.rs
index ef42852f..cea57518 100644
--- a/core/src/point.rs
+++ b/core/src/point.rs
@@ -36,20 +36,26 @@ impl<T: Num> Point<T> {
}
}
-impl From<[f32; 2]> for Point {
- fn from([x, y]: [f32; 2]) -> Self {
+impl<T> From<[T; 2]> for Point<T>
+where
+ T: Num,
+{
+ fn from([x, y]: [T; 2]) -> Self {
Point { x, y }
}
}
-impl From<[u16; 2]> for Point<u16> {
- fn from([x, y]: [u16; 2]) -> Self {
- Point::new(x, y)
+impl<T> From<(T, T)> for Point<T>
+where
+ T: Num,
+{
+ fn from((x, y): (T, T)) -> Self {
+ Self { x, y }
}
}
-impl From<Point> for [f32; 2] {
- fn from(point: Point) -> [f32; 2] {
+impl<T> From<Point<T>> for [T; 2] {
+ fn from(point: Point<T>) -> [T; 2] {
[point.x, point.y]
}
}