Skip to content

Commit 9e3d63d

Browse files
committed
Adjust documents
1 parent 220cbb3 commit 9e3d63d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

futures-async-macro/README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Add this to your `Cargo.toml`:
77

88
```toml
99
[dependencies]
10-
futures-preview = { version = "0.3.0-alpha.14", features = ["async-stream", "nightly"] }
10+
futures-preview = { version = "0.3.0-alpha.15", features = ["async-stream", "nightly"] }
1111
```
1212

1313
### \#\[for_await\]
@@ -17,6 +17,7 @@ Processes streams using a for loop.
1717
This is a reimplement of [futures-await]'s `#[async]` for loops for futures 0.3 and is an experimental implementation of [the idea listed as the next step of async/await](https://github.com/rust-lang/rfcs/blob/master/text/2394-async_await.md#for-await-and-processing-streams).
1818

1919
```rust
20+
#![feature(async_await, generators, stmt_expr_attributes, proc_macro_hygiene)]
2021
use futures::for_await;
2122
use futures::prelude::*;
2223

@@ -26,13 +27,16 @@ for value in stream::iter(1..=5) {
2627
}
2728
```
2829

29-
`value` has the `Item` type of the stream passed in. Note that async for loops can only be used inside of `async` functions or `#[async_stream]` functions.
30+
`value` has the `Item` type of the stream passed in. Note that async for loops can only be used inside of `async` functions, closures, blocks, `#[async_stream]` functions and `async_stream_block!` macros.
3031

3132
### \#\[async_stream\]
3233

34+
Creates streams via generators.
35+
3336
This is a reimplement of [futures-await]'s `#[async_stream]` for futures 0.3 and is an experimental implementation of [the idea listed as the next step of async/await](https://github.com/rust-lang/rfcs/blob/master/text/2394-async_await.md#generators-and-streams).
3437

3538
```rust
39+
#![feature(async_await, generators)]
3640
use futures::prelude::*;
3741
use futures::async_stream;
3842

futures-async-macro/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod error;
1919

2020
mod elision;
2121

22+
/// Processes streams using a for loop.
2223
#[proc_macro_attribute]
2324
pub fn for_await(args: TokenStream, input: TokenStream) -> TokenStream {
2425
assert_!(args.is_empty(), args_is_not_empty!("for_await"));
@@ -28,6 +29,7 @@ pub fn for_await(args: TokenStream, input: TokenStream) -> TokenStream {
2829
Expand(Future).fold_expr(Expr::ForLoop(expr)).into_token_stream().into()
2930
}
3031

32+
/// Creates streams via generators.
3133
#[proc_macro_attribute]
3234
pub fn async_stream(args: TokenStream, input: TokenStream) -> TokenStream {
3335
assert_!(args.is_empty(), args_is_not_empty!("async_stream"));
@@ -180,6 +182,7 @@ fn expand_async_stream_fn(item: ItemFn) -> TokenStream {
180182
})
181183
}
182184

185+
/// Creates streams via generators.
183186
#[proc_macro]
184187
pub fn async_stream_block(input: TokenStream) -> TokenStream {
185188
let input = TokenStream::from(TokenTree::Group(Group::new(Delimiter::Brace, input)));

0 commit comments

Comments
 (0)