Debian Codegraph @

examples/join.rs

raw symbols SCIP
1 use async_fn_streamrust-analyzer cargo async-fn-stream 0.3.2 crate/::fn_streamrust-analyzer cargo async-fn-stream 0.3.2 fn_stream().;
2 use futures_utilrust-analyzer cargo futures-util 0.3.34 crate/::{pin_mutrust-analyzer cargo futures-util 0.3.34 macros/pin_mut!, Streamrust-analyzer cargo futures-core 0.3.34 stream/Stream#, StreamExtrust-analyzer cargo futures-util 0.3.34 stream/stream/StreamExt#};
3
4 fn build_streamrust-analyzer cargo async-fn-stream 0.3.2 build_stream().() -> impl Streamrust-analyzer cargo futures-core 0.3.34 stream/Stream#<Itemrust-analyzer cargo futures-core 0.3.34 stream/Stream#Item# = i32> {
5 fn_streamrust-analyzer cargo async-fn-stream 0.3.2 fn_stream().(|emitter| async move {
6 tokiorust-analyzer cargo tokio 1.53.1 crate/::joinrust-analyzer cargo tokio 1.53.1 macros/join/join!!(
7 async {
8 for i in 0..3 {
9 // yield elements from stream via `emitter`
10 emitter.emitrust-analyzer cargo async-fn-stream 0.3.2 impl#[`StreamEmitter<T>`]emit().(i).rust-analyzer cargo async-fn-stream 0.3.2 impl#[`EmitFuture<'_, T>`][Future]poll().awaitrust-analyzer cargo async-fn-stream 0.3.2 impl#[`EmitFuture<'_, T>`][Future]poll().;
11 }
12 },
13 async {
14 for i in 10..13 {
15 // yield elements from stream via `emitter`
16 emitter.emitrust-analyzer cargo async-fn-stream 0.3.2 impl#[`StreamEmitter<T>`]emit().(i).rust-analyzer cargo async-fn-stream 0.3.2 impl#[`EmitFuture<'_, T>`][Future]poll().awaitrust-analyzer cargo async-fn-stream 0.3.2 impl#[`EmitFuture<'_, T>`][Future]poll().;
17 }
18 }
19 );
20 })
21 }
22
23 async fn examplerust-analyzer cargo async-fn-stream 0.3.2 example().() {
24 let stream = build_streamrust-analyzer cargo async-fn-stream 0.3.2 build_stream().();
25
26 pin_mutrust-analyzer cargo futures-util 0.3.34 macros/pin_mut!!(stream);
27 let mut numbers = Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T>`]new().();
28 while let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(number) = stream.nextrust-analyzer cargo futures-util 0.3.34 stream/stream/StreamExt#next().().rust-analyzer cargo futures-util 0.3.34 stream/stream/next/impl#[`Next<'_, St>`][Future]poll().awaitrust-analyzer cargo futures-util 0.3.34 stream/stream/next/impl#[`Next<'_, St>`][Future]poll(). {
29 printrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!!("{number} ");
30 numbers.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(number);
31 }
32 printlnrust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/println!!();
33 numbers.sort_unstablerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]sort_unstable().();
34 assert_eqrust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/assert_eq!!(numbers, vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0, 1, 2, 10, 11, 12]);
35 }
36
37 #[tokiorust-analyzer cargo tokio 1.53.1 crate/::mainrust-analyzer cargo tokio-macros 2.7.2 main:]
38 async fn mainrust-analyzer cargo async-fn-stream 0.3.2 main().() {
39 futures_executorrust-analyzer cargo futures-executor 0.3.34 crate/::block_onrust-analyzer cargo futures-executor 0.3.34 local_pool/block_on().(examplerust-analyzer cargo async-fn-stream 0.3.2 example().());
40 }