summaryrefslogtreecommitdiff
path: root/src/location.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/location.rs')
-rw-r--r--src/location.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/location.rs b/src/location.rs
index b1b9144..f17965e 100644
--- a/src/location.rs
+++ b/src/location.rs
@@ -1,3 +1,5 @@
+use std::cmp;
+
pub struct Location{
pub x : i32,
pub y : i32
@@ -9,3 +11,33 @@ impl Clone for 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
+ }
+}