Ensure BlockMap::clip_point always yield a valid buffer location

This commit is contained in:
Antonio Scandurra
2021-12-16 12:29:37 +01:00
parent ec39c9d335
commit 64e2f6d506
2 changed files with 55 additions and 19 deletions
+8
View File
@@ -35,6 +35,14 @@ impl Point {
pub fn is_zero(&self) -> bool {
self.row == 0 && self.column == 0
}
pub fn saturating_sub(self, other: Self) -> Self {
if self < other {
Point::zero()
} else {
self - other
}
}
}
impl<'a> Add<&'a Self> for Point {