1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use CoordinateType;
#[derive(PartialEq, Clone, Copy, Debug)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct Coordinate<T>
where
T: CoordinateType,
{
pub x: T,
pub y: T,
}
impl<T: CoordinateType> From<(T, T)> for Coordinate<T> {
fn from(coords: (T, T)) -> Self {
Coordinate {
x: coords.0,
y: coords.1,
}
}
}
impl<T: CoordinateType> From<[T; 2]> for Coordinate<T> {
fn from(coords: [T; 2]) -> Self {
Coordinate {
x: coords[0],
y: coords[1],
}
}
}