We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 50770f5 commit 490c638Copy full SHA for 490c638
vm/src/pyobject.rs
@@ -980,9 +980,12 @@ impl<T> PyIterable<T> {
980
},
981
)?;
982
983
+ let lenhint = objiter::length_hint(vm, iter_obj.clone())?;
984
+
985
Ok(PyIterator {
986
vm,
987
obj: iter_obj,
988
+ lenhint,
989
_item: std::marker::PhantomData,
990
})
991
}
@@ -991,6 +994,7 @@ impl<T> PyIterable<T> {
994
pub struct PyIterator<'a, T> {
992
995
vm: &'a VirtualMachine,
993
996
obj: PyObjectRef,
997
+ lenhint: Option<usize>,
998
_item: std::marker::PhantomData<T>,
999
1000
@@ -1012,6 +1016,10 @@ where
1012
1016
1013
1017
1014
1018
1019
1020
+ fn size_hint(&self) -> (usize, Option<usize>) {
1021
+ (self.lenhint.unwrap_or(0), self.lenhint)
1022
+ }
1015
1023
1024
1025
impl<T> TryFromObject for PyIterable<T>
0 commit comments