Skip to content

Commit 57707fc

Browse files
MajorBreakfastboats
authored andcommitted
Explain use of initialization pattern
1 parent 61062e9 commit 57707fc

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

text/0000-async_await.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,10 +224,10 @@ Future<Output = T>`.
224224
### "Initialization" pattern
225225

226226
One pattern that sometimes occurs is that a future has an "initialization" step
227-
which could ideally happen before the future starts being polled. Because the
228-
async function does not begin evaluating until you poll it, and it captures the
229-
lifetimes of its arguments, this pattern cannot be expressed with a single
230-
`async fn`.
227+
which should be performed during its construction. This is useful when dealing
228+
with data conversion and temporary borrows. Because the async function does not
229+
begin evaluating until you poll it, and it captures the lifetimes of its
230+
arguments, this pattern cannot be expressed directly with an `async fn`.
231231

232232
One option is to write a function that returns `impl Future` using a closure
233233
which is evaluated immediately:

0 commit comments

Comments
 (0)