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
use winapi::um::wincon::COORD;
#[derive(Copy, Clone, Debug, Default, Eq, PartialEq, PartialOrd)]
pub struct Coord {
pub x: i16,
pub y: i16,
}
impl Coord {
pub fn new(x: i16, y: i16) -> Coord {
Coord { x, y }
}
}
impl From<COORD> for Coord {
fn from(coord: COORD) -> Self {
Coord::new(coord.X, coord.Y)
}
}
impl From<Coord> for COORD {
fn from(location: Coord) -> Self {
COORD {
X: location.x,
Y: location.y,
}
}
}
impl Into<(u16, u16)> for Coord {
fn into(self) -> (u16, u16) {
(self.x as u16, self.y as u16)
}
}