From a019cbf02cd254b7a2c322be8204f9ec6f111302 Mon Sep 17 00:00:00 2001 From: gnsxun <105912995+gnsxun@users.noreply.github.com> Date: Mon, 23 May 2022 04:38:11 +0900 Subject: [PATCH] Add count.reduce() (#3737) --- vm/src/stdlib/itertools.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vm/src/stdlib/itertools.rs b/vm/src/stdlib/itertools.rs index bd4de3ce0..cad3dca66 100644 --- a/vm/src/stdlib/itertools.rs +++ b/vm/src/stdlib/itertools.rs @@ -193,7 +193,15 @@ mod decl { } #[pyimpl(with(IterNext, Constructor))] - impl PyItertoolsCount {} + impl PyItertoolsCount { + // TODO: Implement this + // if (lz->cnt == PY_SSIZE_T_MAX) + // return Py_BuildValue("0(00)", Py_TYPE(lz), lz->long_cnt, lz->long_step); + #[pymethod(magic)] + fn reduce(zelf: PyRef) -> (PyTypeRef, (BigInt,)) { + (zelf.class().clone(), (zelf.cur.read().clone(),)) + } + } impl IterNextIterable for PyItertoolsCount {} impl IterNext for PyItertoolsCount { fn next(zelf: &Py, vm: &VirtualMachine) -> PyResult {