Skip to content

Commit 975587b

Browse files
authored
Add .size_hint() implementation for ArchiveSymbolIterator (gimli-rs#759)
This uses the size hint value from the underlying `slice::Iter`. The iterator itself does not track the symbol count so this slice iter provides the most accurate value
1 parent e764a2d commit 975587b

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/read/archive.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,20 @@ impl<'data> Iterator for ArchiveSymbolIterator<'data> {
802802
}
803803
}
804804
}
805+
806+
fn size_hint(&self) -> (usize, Option<usize>) {
807+
match &self.0 {
808+
SymbolIteratorInternal::None => (0, None),
809+
SymbolIteratorInternal::Gnu { offsets, .. } => offsets.size_hint(),
810+
SymbolIteratorInternal::Gnu64 { offsets, .. } => offsets.size_hint(),
811+
SymbolIteratorInternal::Bsd { offsets, .. } => offsets.size_hint(),
812+
SymbolIteratorInternal::Bsd64 { offsets, .. } => offsets.size_hint(),
813+
SymbolIteratorInternal::Coff { indices, .. } => {
814+
// The `slice::Iter` is in the indices field for this variant
815+
indices.size_hint()
816+
}
817+
}
818+
}
805819
}
806820

807821
/// A symbol in the archive symbol table.

0 commit comments

Comments
 (0)