Perform consistency check when reexporting

This commit is contained in:
Joscha 2022-10-03 18:11:37 +02:00
parent e74eee89e6
commit d910047b48
3 changed files with 13 additions and 6 deletions

View file

@ -24,6 +24,15 @@ pub struct AdjacencyList {
}
impl AdjacencyList {
pub fn check_consistency(&self) {
let range = 0..self.pages.len() as u32;
for link in &self.links {
if !range.contains(&link.to) {
panic!("Invalid link detected!");
}
}
}
pub fn write<W: Write>(&self, mut to: W) -> io::Result<()> {
let n_pages: u32 = self.pages.len() as u32;
to.write_all(&n_pages.to_le_bytes())?;