Point3 supports try_into typing for coordinates.
use std::ops;
+use std::convert::TryInto;
#[cfg_attr(
feature = "serialization",
@@ -14,8 +15,14 @@ pub struct Point3 {
impl Point3 {
/// Create a new point from an x/y/z coordinate.
- pub fn new(x: i32, y: i32, z: i32) -> Point3 {
- Point3 { x, y, z }
+ pub fn new<T>(x: T, y: T, z: T) -> Point3
+ where T : TryInto<i32>
+ {
+ Point3 {
+ x : x.try_into().ok().unwrap(),
+ y : y.try_into().ok().unwrap(),
+ z : z.try_into().ok().unwrap()
+ }
}
}
