vec: Add a debug assertion where TrustedLen is used
This commit is contained in:
parent
622f24f6d9
commit
ee84ec1fa1
1 changed files with 7 additions and 1 deletions
|
|
@ -1578,7 +1578,13 @@ impl<I> IsTrustedLen for I where I: Iterator { }
|
|||
impl<I> IsTrustedLen for I where I: TrustedLen
|
||||
{
|
||||
fn trusted_len(&self) -> Option<usize> {
|
||||
self.size_hint().1
|
||||
let (low, high) = self.size_hint();
|
||||
if let Some(high_value) = high {
|
||||
debug_assert_eq!(low, high_value,
|
||||
"TrustedLen iterator's size hint is not exact: {:?}",
|
||||
(low, high));
|
||||
}
|
||||
high
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue