@@ -116,39 +116,47 @@ mod decl {
116116 #[ derive( Debug , PyPayload ) ]
117117 struct PyItertoolsCompress {
118118 data : PyIter ,
119- selector : PyIter ,
119+ selectors : PyIter ,
120120 }
121121
122122 #[ derive( FromArgs ) ]
123123 struct CompressNewArgs {
124- #[ pyarg( positional ) ]
124+ #[ pyarg( any ) ]
125125 data : PyIter ,
126- #[ pyarg( positional ) ]
127- selector : PyIter ,
126+ #[ pyarg( any ) ]
127+ selectors : PyIter ,
128128 }
129129
130130 impl Constructor for PyItertoolsCompress {
131131 type Args = CompressNewArgs ;
132132
133133 fn py_new (
134134 cls : PyTypeRef ,
135- Self :: Args { data, selector } : Self :: Args ,
135+ Self :: Args { data, selectors } : Self :: Args ,
136136 vm : & VirtualMachine ,
137137 ) -> PyResult {
138- PyItertoolsCompress { data, selector }
138+ PyItertoolsCompress { data, selectors }
139139 . into_ref_with_type ( vm, cls)
140140 . map ( Into :: into)
141141 }
142142 }
143143
144144 #[ pyimpl( with( IterNext , Constructor ) ) ]
145- impl PyItertoolsCompress { }
145+ impl PyItertoolsCompress {
146+ #[ pymethod( magic) ]
147+ fn reduce ( zelf : PyRef < Self > ) -> ( PyTypeRef , ( PyIter , PyIter ) ) {
148+ (
149+ zelf. class ( ) . clone ( ) ,
150+ ( zelf. data . clone ( ) , zelf. selectors . clone ( ) ) ,
151+ )
152+ }
153+ }
146154
147155 impl IterNextIterable for PyItertoolsCompress { }
148156 impl IterNext for PyItertoolsCompress {
149157 fn next ( zelf : & Py < Self > , vm : & VirtualMachine ) -> PyResult < PyIterReturn > {
150158 loop {
151- let sel_obj = match zelf. selector . next ( vm) ? {
159+ let sel_obj = match zelf. selectors . next ( vm) ? {
152160 PyIterReturn :: Return ( obj) => obj,
153161 PyIterReturn :: StopIteration ( v) => return Ok ( PyIterReturn :: StopIteration ( v) ) ,
154162 } ;
0 commit comments