Skip to content

Commit 86dcfaf

Browse files
author
Andrew J Westlake
committed
Fixed some examples in the docs
1 parent dcb073b commit 86dcfaf

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/async_std.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ where
8888
/// let secs = secs.extract()?;
8989
///
9090
/// pyo3_asyncio::async_std::into_coroutine(py, async move {
91-
/// tokio::time::sleep(Duration::from_secs(secs)).await;
91+
/// async_std::task::sleep(Duration::from_secs(secs)).await;
9292
/// Python::with_gil(|py| Ok(py.None()))
93-
/// })
93+
/// })
9494
/// }
9595
/// ```
9696
pub fn into_coroutine<F>(py: Python, fut: F) -> PyResult<PyObject>

src/generic.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ fn set_result(py: Python, future: &PyAny, result: PyResult<PyObject>) -> PyResul
158158
/// #
159159
/// # struct MyCustomRuntime;
160160
/// #
161+
/// # impl MyCustomRuntime {
162+
/// # async fn sleep(_: Duration) {
163+
/// # unreachable!()
164+
/// # }
165+
/// # }
166+
/// #
161167
/// # impl Runtime for MyCustomRuntime {
162168
/// # type JoinError = MyCustomJoinError;
163169
/// # type JoinHandle = MyCustomJoinHandle;
@@ -180,7 +186,7 @@ fn set_result(py: Python, future: &PyAny, result: PyResult<PyObject>) -> PyResul
180186
/// let secs = secs.extract()?;
181187
///
182188
/// pyo3_asyncio::generic::into_coroutine::<MyCustomRuntime, _>(py, async move {
183-
/// tokio::time::sleep(Duration::from_secs(secs)).await;
189+
/// MyCustomRuntime::sleep(Duration::from_secs(secs)).await;
184190
/// Python::with_gil(|py| Ok(py.None()))
185191
/// })
186192
/// }

src/tokio.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ where
141141
/// pyo3_asyncio::tokio::into_coroutine(py, async move {
142142
/// tokio::time::sleep(Duration::from_secs(secs)).await;
143143
/// Python::with_gil(|py| Ok(py.None()))
144-
/// })
144+
/// })
145145
/// }
146146
/// ```
147147
pub fn into_coroutine<F>(py: Python, fut: F) -> PyResult<PyObject>

0 commit comments

Comments
 (0)