mirror of
https://github.com/rust-osdev/uefi-rs
synced 2026-08-26 18:26:05 -04:00
uefi: report remaining memory map entries
ExactSizeIterator::len must return the number of items still available. Account for the iterator index after entries have been consumed.
This commit is contained in:
parent
53c321db71
commit
bab00950ba
2 changed files with 5 additions and 1 deletions
|
|
@ -513,6 +513,10 @@ mod tests {
|
|||
mmap.entries().copied().collect::<Vec<_>>().as_slice(),
|
||||
&BASE_MMAP_UNSORTED
|
||||
);
|
||||
let mut entries = mmap.entries();
|
||||
assert_eq!(entries.len(), 3);
|
||||
assert!(entries.next().is_some());
|
||||
assert_eq!(entries.len(), 2);
|
||||
assert!(!mmap.is_sorted());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,6 @@ impl<'a> Iterator for MemoryMapIter<'a> {
|
|||
|
||||
impl ExactSizeIterator for MemoryMapIter<'_> {
|
||||
fn len(&self) -> usize {
|
||||
self.memory_map.len()
|
||||
self.memory_map.len() - self.index
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue