blob: f17965ed3e6ef034ba77ba416761aafbfee2b52e (
plain)
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
|
use std::cmp;
pub struct Location{
pub x : i32,
pub y : i32
}
impl Copy for Location {}
impl Clone for Location {
fn clone(&self) -> Location {
*self
}
}
impl cmp::PartialEq for Location {
fn eq(&self, rhs : &Location) -> bool {
if self.x == rhs.x && self.y == rhs.y {
true
}
else {
false
}
}
}
impl Location {
pub fn up(mut self) -> Location {
self.y += 1;
self
}
pub fn down(mut self) -> Location {
self.y -= 1;
self
}
pub fn right(mut self) -> Location {
self.x += 1;
self
}
pub fn left(mut self) -> Location {
self.x -= 1;
self
}
}
|