Skip to content

Commit a019cbf

Browse files
author
gnsxun
authored
Add count.reduce() (RustPython#3737)
1 parent 94240f1 commit a019cbf

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

vm/src/stdlib/itertools.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,15 @@ mod decl {
193193
}
194194

195195
#[pyimpl(with(IterNext, Constructor))]
196-
impl PyItertoolsCount {}
196+
impl PyItertoolsCount {
197+
// TODO: Implement this
198+
// if (lz->cnt == PY_SSIZE_T_MAX)
199+
// return Py_BuildValue("0(00)", Py_TYPE(lz), lz->long_cnt, lz->long_step);
200+
#[pymethod(magic)]
201+
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (BigInt,)) {
202+
(zelf.class().clone(), (zelf.cur.read().clone(),))
203+
}
204+
}
197205
impl IterNextIterable for PyItertoolsCount {}
198206
impl IterNext for PyItertoolsCount {
199207
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {

0 commit comments

Comments
 (0)