Debian Codegraph @

examples/async_std.rs

raw symbols SCIP
1 use pyo3rust-analyzer cargo pyo3 0.28.0 crate/::preluderust-analyzer cargo pyo3 0.28.0 prelude/::*;
2
3 #[pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::async_stdrust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/::mainrust-analyzer cargo pyo3-async-runtimes-macros 0.28.0 async_std_main:]
4 async fn main() -> PyResultrust-analyzer cargo pyo3 0.28.0 err/PyResult#<()> {
5 let fut = Pythonrust-analyzer cargo pyo3 0.28.0 marker/Python#::attachrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'_>`]attach().(|py| {
6 let asyncio = py.importrust-analyzer cargo pyo3 0.28.0 marker/impl#[`Python<'py>`]import().("asyncio")?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
7
8 // convert asyncio.sleep into a Rust Future
9 pyo3_async_runtimesrust-analyzer cargo pyo3-async-runtimes 0.28.0 crate/::async_stdrust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/::into_futurerust-analyzer cargo pyo3-async-runtimes 0.28.0 async_std/into_future().(asyncio.call_method1rust-analyzer cargo pyo3 0.28.0 types/any/impl#[`Bound<'py, PyAny>`][`PyAnyMethods<'py>`]call_method1().("sleep", (1,))?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)
10 })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
11
12 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("sleeping for 1s");
13 fut.rust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().awaitrust-analyzer cargo core https://github.com/rust-lang/rust/library/core future/future/Future#poll().?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().;
14 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!("done");
15
16 Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(())
17 }