提交 ee84ec1f 编写于 作者: U Ulrik Sverdrup

vec: Add a debug assertion where TrustedLen is used

上级 622f24f6
......@@ -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
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册