Make BlockMap unit test pass with 2d coordinates

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2021-11-15 16:30:58 +01:00
parent 3154ccbafe
commit 296944e34d
3 changed files with 127 additions and 82 deletions

View file

@ -23,6 +23,15 @@ impl Point {
Point::new(0, 0)
}
pub fn from_str(s: &str) -> Self {
let mut point = Self::zero();
for (row, line) in s.split('\n').enumerate() {
point.row = row as u32;
point.column = line.len() as u32;
}
point
}
pub fn is_zero(&self) -> bool {
self.row == 0 && self.column == 0
}