diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 50ad48567472..8bed02c79e0a 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -1578,7 +1578,13 @@ impl IsTrustedLen for I where I: Iterator { } impl IsTrustedLen for I where I: TrustedLen { fn trusted_len(&self) -> Option { - 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 } }