diff options
Diffstat (limited to 'src/grid.rs')
-rw-r--r-- | src/grid.rs | 28 |
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>, |