rust/library/core/src/future
Matthias Krüger 663fb5a0e9
Rollup merge of #109970 - danielhenrymantilla:add-poll-fn-pin-clarifications, r=thomcc
[doc] `poll_fn`: explain how to `pin` captured state safely

Usage of `Pin::new_unchecked(&mut …)` is dangerous with `poll_fn`, even though the `!Unpin`-infectiousness has made things smoother. Nonetheless, there are easy ways to avoid the need for any `unsafe` altogether, be it through `Box::pin`ning, or the `pin!` macro. Since the latter only works within an `async` context, showing an example artificially introducing one ought to help people navigate this subtlety with safety and confidence.

## Preview

https://user-images.githubusercontent.com/9920355/230092494-da22fdcb-0b8f-4ff4-a2ac-aa7d9ead077a.mov

```@rustbot``` label +A-docs
2023-06-19 19:26:25 +02:00
..
future.rs Suggest more impl Trait on -> _ 2023-01-03 23:50:31 +00:00
into_future.rs Don't call await a method 2023-04-27 17:18:12 +00:00
join.rs tidy 2023-05-19 12:45:41 +02:00
mod.rs Remove identity_future from stdlib 2023-05-07 10:52:01 +02:00
pending.rs Also change PhantomData parameter of iter::Empty, and future::Pending 2022-01-07 01:53:51 +01:00
poll_fn.rs [doc] poll_fn: explain how to pin captured state safely 2023-06-18 09:56:13 +00:00
ready.rs Implement Ready::into_inner() 2022-08-30 13:39:30 +02:00