1+ use crate :: pyobject:: {
2+ PyContext , PyFuncArgs , PyObject , PyObjectPayload , PyObjectPayload2 , PyObjectRef , PyResult ,
3+ TypeProtocol ,
4+ } ;
5+ use crate :: vm:: VirtualMachine ;
6+
17use super :: objiter;
2- use crate :: pyobject:: { PyContext , PyFuncArgs , PyObject , PyObjectPayload , PyResult , TypeProtocol } ;
3- use crate :: vm:: VirtualMachine ; // Required for arg_check! to use isinstance
8+
9+ #[ derive( Debug ) ]
10+ pub struct PyZip {
11+ iterators : Vec < PyObjectRef > ,
12+ }
13+
14+ impl PyObjectPayload2 for PyZip {
15+ fn required_type ( ctx : & PyContext ) -> PyObjectRef {
16+ ctx. zip_type ( )
17+ }
18+ }
419
520fn zip_new ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
621 no_kwargs ! ( vm, args) ;
@@ -11,15 +26,17 @@ fn zip_new(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
1126 . map ( |iterable| objiter:: get_iter ( vm, iterable) )
1227 . collect :: < Result < Vec < _ > , _ > > ( ) ?;
1328 Ok ( PyObject :: new (
14- PyObjectPayload :: ZipIterator { iterators } ,
29+ PyObjectPayload :: AnyRustValue {
30+ value : Box :: new ( PyZip { iterators } ) ,
31+ } ,
1532 cls. clone ( ) ,
1633 ) )
1734}
1835
1936fn zip_next ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
2037 arg_check ! ( vm, args, required = [ ( zip, Some ( vm. ctx. zip_type( ) ) ) ] ) ;
2138
22- if let PyObjectPayload :: ZipIterator { ref iterators } = zip. payload {
39+ if let Some ( PyZip { ref iterators } ) = zip. payload ( ) {
2340 if iterators. is_empty ( ) {
2441 Err ( objiter:: new_stop_iteration ( vm) )
2542 } else {
0 commit comments