summaryrefslogtreecommitdiffstats
path: root/src/grid.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-12-23 12:18:46 -0500
committerJesse Luehrs <doy@tozt.net>2021-12-23 12:28:59 -0500
commit8d117c794835091d3c3416fc5944149372bd369c (patch)
treeb03a6076e5fb1e85676e76ec5d3a3a4cd37d08ad /src/grid.rs
parent747c6c27661f982ce0a7da06b99d35b173d3bf1a (diff)
downloadadvent-of-code-8d117c794835091d3c3416fc5944149372bd369c.tar.gz
advent-of-code-8d117c794835091d3c3416fc5944149372bd369c.zip
factor out pathfinding
Diffstat (limited to 'src/grid.rs')
-rw-r--r--src/grid.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/grid.rs b/src/grid.rs
index c0607c0..46f6263 100644
--- a/src/grid.rs
+++ b/src/grid.rs
@@ -31,6 +31,34 @@ impl std::ops::Add<Col> for usize {
}
}
+impl std::ops::Sub<usize> for Row {
+ type Output = Self;
+ fn sub(self, other: usize) -> Self::Output {
+ Self(self.0 - other)
+ }
+}
+
+impl std::ops::Sub<Row> for usize {
+ type Output = Row;
+ fn sub(self, other: Row) -> Self::Output {
+ Row(self - other.0)
+ }
+}
+
+impl std::ops::Sub<usize> for Col {
+ type Output = Self;
+ fn sub(self, other: usize) -> Self::Output {
+ Self(self.0 - other)
+ }
+}
+
+impl std::ops::Sub<Col> for usize {
+ type Output = Col;
+ fn sub(self, other: Col) -> Self::Output {
+ Col(self - other.0)
+ }
+}
+
#[derive(Default, Clone, Debug)]
pub struct GridRow<T: Default + Clone> {
cells: Vec<T>,