forked from georust/geo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcoord.rs
64 lines (48 loc) · 1.06 KB
/
coord.rs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
use geo_types::{Coord, CoordNum, Point};
pub trait CoordTrait: Send + Sync {
type T: CoordNum + Send + Sync;
/// x component of this coord
fn x(&self) -> Self::T;
/// y component of this coord
fn y(&self) -> Self::T;
/// Returns a tuple that contains the x/horizontal & y/vertical component of the coord.
fn x_y(&self) -> (Self::T, Self::T) {
(self.x(), self.y())
}
}
impl<T: CoordNum + Send + Sync> CoordTrait for Point<T> {
type T = T;
fn x(&self) -> T {
self.0.x
}
fn y(&self) -> T {
self.0.y
}
}
impl<T: CoordNum + Send + Sync> CoordTrait for &Point<T> {
type T = T;
fn x(&self) -> T {
self.0.x
}
fn y(&self) -> T {
self.0.y
}
}
impl<T: CoordNum + Send + Sync> CoordTrait for Coord<T> {
type T = T;
fn x(&self) -> T {
self.x
}
fn y(&self) -> T {
self.y
}
}
impl<T: CoordNum + Send + Sync> CoordTrait for &Coord<T> {
type T = T;
fn x(&self) -> T {
self.x
}
fn y(&self) -> T {
self.y
}
}