File tree Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Expand file tree Collapse file tree 1 file changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -980,9 +980,12 @@ impl<T> PyIterable<T> {
980
980
} ,
981
981
) ?;
982
982
983
+ let lenhint = objiter:: length_hint ( vm, iter_obj. clone ( ) ) ?;
984
+
983
985
Ok ( PyIterator {
984
986
vm,
985
987
obj : iter_obj,
988
+ lenhint,
986
989
_item : std:: marker:: PhantomData ,
987
990
} )
988
991
}
@@ -991,6 +994,7 @@ impl<T> PyIterable<T> {
991
994
pub struct PyIterator < ' a , T > {
992
995
vm : & ' a VirtualMachine ,
993
996
obj : PyObjectRef ,
997
+ lenhint : Option < usize > ,
994
998
_item : std:: marker:: PhantomData < T > ,
995
999
}
996
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
}
1016
1024
1017
1025
impl < T > TryFromObject for PyIterable < T >
You can’t perform that action at this time.
0 commit comments