borrow checker: add method to check that its empty

This commit is contained in:
Pat Hickey
2020-05-18 19:15:04 -07:00
parent d221a3a346
commit a4c1079b50

View File

@@ -25,6 +25,9 @@ impl BorrowChecker {
pub fn is_borrowed(&self, r: Region) -> bool { pub fn is_borrowed(&self, r: Region) -> bool {
self.bc.borrow().is_borrowed(r) self.bc.borrow().is_borrowed(r)
} }
pub fn is_empty(&self) -> bool {
self.bc.borrow().is_empty()
}
} }
#[derive(Debug)] #[derive(Debug)]
@@ -41,6 +44,10 @@ impl InnerBorrowChecker {
} }
} }
fn is_empty(&self) -> bool {
self.borrows.is_empty()
}
fn is_borrowed(&self, r: Region) -> bool { fn is_borrowed(&self, r: Region) -> bool {
!self.borrows.values().all(|b| !b.overlaps(r)) !self.borrows.values().all(|b| !b.overlaps(r))
} }