about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorUlrik Sverdrup <bluss@users.noreply.github.com>2016-10-21 19:18:08 +0200
committerUlrik Sverdrup <bluss@users.noreply.github.com>2016-10-21 19:18:08 +0200
commitee84ec1fa183dbfa9ce2e26e6e8c12ded3ffddb6 (patch)
tree5f4d48d0e990fc828c8fc4f6809dea804a345dbe /src
parent622f24f6d9cc952ccf2bb4dbe5bf65bb966194d3 (diff)
downloadrust-ee84ec1fa183dbfa9ce2e26e6e8c12ded3ffddb6.tar.gz
rust-ee84ec1fa183dbfa9ce2e26e6e8c12ded3ffddb6.zip
vec: Add a debug assertion where TrustedLen is used
Diffstat (limited to 'src')
-rw-r--r--src/libcollections/vec.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs
index 50ad4856747..8bed02c79e0 100644
--- a/src/libcollections/vec.rs
+++ b/src/libcollections/vec.rs
@@ -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
     }
 }