From 1e0992a85db1f29a74291d797ae1f2f9e47abe9f Mon Sep 17 00:00:00 2001 From: Joseph Perez Date: Mon, 20 Nov 2023 01:25:25 +0100 Subject: [PATCH] style: make clippy happy --- src/coroutine.rs | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/src/coroutine.rs b/src/coroutine.rs index 52f39018ec8..a530184a1c3 100644 --- a/src/coroutine.rs +++ b/src/coroutine.rs @@ -1,30 +1,36 @@ //! Python coroutine implementation, used notably when wrapping `async fn` //! with `#[pyfunction]`/`#[pymethods]`. -use crate::coroutine::waker::AsyncioWaker; -use crate::exceptions::{PyRuntimeError, PyStopIteration}; -use crate::panic::PanicException; -use crate::pyclass::IterNextOutput; -use crate::types::PyIterator; -use crate::{IntoPy, Py, PyAny, PyErr, PyObject, PyResult, Python}; +use std::{ + any::Any, + future::Future, + panic, + pin::Pin, + sync::Arc, + task::{Context, Poll}, +}; + use futures_util::FutureExt; use pyo3_macros::{pyclass, pymethods}; -use std::any::Any; -use std::future::Future; -use std::panic; -use std::pin::Pin; -use std::sync::Arc; -use std::task::{Context, Poll}; + +use crate::{ + coroutine::waker::AsyncioWaker, + exceptions::{PyRuntimeError, PyStopIteration}, + panic::PanicException, + pyclass::IterNextOutput, + types::PyIterator, + IntoPy, Py, PyAny, PyErr, PyObject, PyResult, Python, +}; mod waker; const COROUTINE_REUSED_ERROR: &str = "cannot reuse already awaited coroutine"; +type FutureOutput = Result, Box>; + /// Python coroutine wrapping a [`Future`]. #[pyclass(crate = "crate")] pub struct Coroutine { - future: Option< - Pin, Box>> + Send>>, - >, + future: Option + Send>>>, waker: Option>, }