Skip to content

Commit

Permalink
style: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Perez committed Nov 20, 2023
1 parent 6ab305b commit 1e0992a
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/coroutine.rs
Original file line number Diff line number Diff line change
@@ -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<PyResult<PyObject>, Box<dyn Any + Send>>;

/// Python coroutine wrapping a [`Future`].
#[pyclass(crate = "crate")]
pub struct Coroutine {
future: Option<
Pin<Box<dyn Future<Output = Result<PyResult<PyObject>, Box<dyn Any + Send>>> + Send>>,
>,
future: Option<Pin<Box<dyn Future<Output = FutureOutput> + Send>>>,
waker: Option<Arc<AsyncioWaker>>,
}

Expand Down

0 comments on commit 1e0992a

Please sign in to comment.