File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -130,6 +130,22 @@ pub trait Stream {
130
130
131
131
/// Transforms a stream into a collection.
132
132
///
133
+ /// `collect()` can take anything streamable, and turn it into a relevant
134
+ /// collection. This is one of the more powerful methods in the async
135
+ /// standard library, used in a variety of contexts.
136
+ ///
137
+ /// The most basic pattern in which `collect()` is used is to turn one
138
+ /// collection into another. You take a collection, call [`stream`] on it,
139
+ /// do a bunch of transformations, and then `collect()` at the end.
140
+ ///
141
+ /// Because `collect()` is so general, it can cause problems with type
142
+ /// inference. As such, `collect()` is one of the few times you'll see
143
+ /// the syntax affectionately known as the 'turbofish': `::<>`. This
144
+ /// helps the inference algorithm understand specifically which collection
145
+ /// you're trying to collect into.
146
+ ///
147
+ /// # Examples
148
+ ///
133
149
/// ```
134
150
/// # fn main() { async_std::task::block_on(async {
135
151
/// #
@@ -143,6 +159,8 @@ pub trait Stream {
143
159
/// #
144
160
/// # }) }
145
161
/// ```
162
+ ///
163
+ /// [`stream`]: trait.Stream.html#tymethod.next
146
164
#[ must_use = "if you really need to exhaust the iterator, consider `.for_each(drop)` instead (TODO)" ]
147
165
fn collect < ' a , B : FromStream < <Self as Stream >:: Item > > ( self ) -> dyn_ret ! ( ' a, B )
148
166
where
You can’t perform that action at this time.
0 commit comments