Skip to content

Commit 8fd984a

Browse files
committed
clean up coroutine
1 parent 1db415d commit 8fd984a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

vm/src/builtins/coroutine.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ impl PyCoroutine {
4545
}
4646

4747
#[pymethod]
48-
fn send(zelf: PyRef<Self>, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
48+
fn send(zelf: &Py<Self>, value: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
4949
zelf.inner.send(zelf.as_object(), value, vm)
5050
}
5151

5252
#[pymethod]
5353
fn throw(
54-
zelf: PyRef<Self>,
54+
zelf: &Py<Self>,
5555
exc_type: PyObjectRef,
5656
exc_val: OptionalArg,
5757
exc_tb: OptionalArg,
@@ -67,7 +67,7 @@ impl PyCoroutine {
6767
}
6868

6969
#[pymethod]
70-
fn close(zelf: PyRef<Self>, vm: &VirtualMachine) -> PyResult<()> {
70+
fn close(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<()> {
7171
zelf.inner.close(zelf.as_object(), vm)
7272
}
7373

@@ -111,7 +111,7 @@ impl Representable for PyCoroutine {
111111
impl IterNextIterable for PyCoroutine {}
112112
impl IterNext for PyCoroutine {
113113
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
114-
Self::send(zelf.to_owned(), vm.ctx.none(), vm)
114+
Self::send(zelf, vm.ctx.none(), vm)
115115
}
116116
}
117117

@@ -131,8 +131,8 @@ impl PyPayload for PyCoroutineWrapper {
131131
#[pyclass(with(IterNext))]
132132
impl PyCoroutineWrapper {
133133
#[pymethod]
134-
fn send(zelf: PyRef<Self>, val: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
135-
PyCoroutine::send(zelf.coro.clone(), val, vm)
134+
fn send(&self, val: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
135+
PyCoroutine::send(&self.coro, val, vm)
136136
}
137137

138138
#[pymethod]
@@ -143,14 +143,14 @@ impl PyCoroutineWrapper {
143143
exc_tb: OptionalArg,
144144
vm: &VirtualMachine,
145145
) -> PyResult<PyIterReturn> {
146-
PyCoroutine::throw(self.coro.clone(), exc_type, exc_val, exc_tb, vm)
146+
PyCoroutine::throw(&self.coro, exc_type, exc_val, exc_tb, vm)
147147
}
148148
}
149149

150150
impl IterNextIterable for PyCoroutineWrapper {}
151151
impl IterNext for PyCoroutineWrapper {
152152
fn next(zelf: &Py<Self>, vm: &VirtualMachine) -> PyResult<PyIterReturn> {
153-
Self::send(zelf.to_owned(), vm.ctx.none(), vm)
153+
Self::send(zelf, vm.ctx.none(), vm)
154154
}
155155
}
156156

0 commit comments

Comments
 (0)