diff options
author | 2024-01-12 14:41:40 +0100 | |
---|---|---|
committer | 2024-01-12 14:41:40 +0100 | |
commit | 50c310fd9f692eafb2350827636ffbd6d7b6c9b9 (patch) | |
tree | 0f1ab4182a0cce7469e01881c095e0c3988b3f9a /core/src/point.rs | |
parent | 63e9adac56e9a4f21ec82137329d7c455fbf630b (diff) | |
parent | 11474bdc3e1a43e6c167d7b98f22d87933dbd2b6 (diff) | |
download | iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.tar.gz iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.tar.bz2 iced-50c310fd9f692eafb2350827636ffbd6d7b6c9b9.zip |
Merge pull request #2192 from iced-rs/fix/layout-inconsistencies
Layout consistency
Diffstat (limited to 'core/src/point.rs')
-rw-r--r-- | core/src/point.rs | 20 |
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] } } |