Skip to content

Commit 29055ab

Browse files
committed
clean up enumerate
1 parent 29073cf commit 29055ab

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

vm/src/builtins/enumerate.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::{
88
function::OptionalArg,
99
protocol::{PyIter, PyIterReturn},
1010
types::{Constructor, IterNext, IterNextIterable},
11-
AsObject, Context, Py, PyObjectRef, PyPayload, PyRef, PyResult, VirtualMachine,
11+
AsObject, Context, Py, PyObjectRef, PyPayload, PyResult, VirtualMachine,
1212
};
1313
use num_bigint::BigInt;
1414
use num_traits::Zero;
@@ -51,17 +51,21 @@ impl Constructor for PyEnumerate {
5151
}
5252
}
5353

54-
#[pyclass(with(IterNext, Constructor), flags(BASETYPE))]
54+
#[pyclass(with(Py, IterNext, Constructor), flags(BASETYPE))]
5555
impl PyEnumerate {
5656
#[pyclassmethod(magic)]
5757
fn class_getitem(cls: PyTypeRef, args: PyObjectRef, vm: &VirtualMachine) -> PyGenericAlias {
5858
PyGenericAlias::new(cls, args, vm)
5959
}
60+
}
61+
62+
#[pyclass]
63+
impl Py<PyEnumerate> {
6064
#[pymethod(magic)]
61-
fn reduce(zelf: PyRef<Self>) -> (PyTypeRef, (PyIter, BigInt)) {
65+
fn reduce(&self) -> (PyTypeRef, (PyIter, BigInt)) {
6266
(
63-
zelf.class().to_owned(),
64-
(zelf.iterator.clone(), zelf.counter.read().clone()),
67+
self.class().to_owned(),
68+
(self.iterator.clone(), self.counter.read().clone()),
6569
)
6670
}
6771
}

0 commit comments

Comments
 (0)