We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 612f234 commit b8db69eCopy full SHA for b8db69e
src/types/list.rs
@@ -1765,4 +1765,25 @@ mod tests {
1765
assert_eq!(list.iter().count(), 3);
1766
})
1767
}
1768
+
1769
+ #[test]
1770
+ fn test_new_from_non_exact_iter() {
1771
+ Python::attach(|py| {
1772
+ let iter = (0..5)
1773
+ .filter(|_| true) // Filter does not implement ExactSizeIterator
1774
+ .map(|item| item.into_pyobject(py).unwrap());
1775
1776
+ assert!(
1777
+ matches!(iter.size_hint(), (0, _)),
1778
+ "size_hint lower bound should be 0 because we do not now the final size after filer"
1779
+ );
1780
1781
+ let list = PyList::new(py, iter).unwrap();
1782
+ assert_eq!(
1783
+ list.len(),
1784
+ 5,
1785
+ "list should contain all elements even though size_hint is 0"
1786
1787
+ })
1788
+ }
1789
0 commit comments