From 2814e09d31ed245e64d3e6fd9ace4848169b0d8e Mon Sep 17 00:00:00 2001 From: Shane Pearman Date: Sat, 31 Mar 2018 12:42:22 -0700 Subject: [PATCH] Add from array impl for points. --- src/geometry/point_construction.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/geometry/point_construction.rs b/src/geometry/point_construction.rs index 8f06629f..2282354f 100644 --- a/src/geometry/point_construction.rs +++ b/src/geometry/point_construction.rs @@ -125,3 +125,15 @@ componentwise_constructors_impl!( U5, x:0, y:1, z:2, w:3, a:4; U6, x:0, y:1, z:2, w:3, a:4, b:5; ); + +macro_rules! from_array_impl( + ($($D: ty, $len: expr);*) => {$( + impl From <[N; $len]> for Point { + fn from (coords : [N; $len]) -> Self { + Point::from_coordinates(coords.into()) + } + } + )*} +); + +from_array_impl!(U1,1; U2,2; U3,3; U4,4; U5,5; U6,6);