Make BlockMap
unit test pass with 2d coordinates
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
3154ccbafe
commit
296944e34d
3 changed files with 127 additions and 82 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue