diff options
| author | Mazdak Farrokhzad <twingoow@gmail.com> | 2019-04-26 03:50:16 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-04-26 03:50:16 +0200 |
| commit | 8bdb91d9ffc9d5f008dae971faadcb06cf2a3bb9 (patch) | |
| tree | 2311c0dfcf475c6e72daa5bab966096bbc41020d /src/libstd/sys | |
| parent | 878a7d6ea5ddbc5f813bd45dbb3633e4317ad2a9 (diff) | |
| parent | a0e0849a3b1710139d84be846a444c12297cfd2b (diff) | |
| download | rust-8bdb91d9ffc9d5f008dae971faadcb06cf2a3bb9.tar.gz rust-8bdb91d9ffc9d5f008dae971faadcb06cf2a3bb9.zip | |
Rollup merge of #60165 - Nemo157:pin-into-inner, r=cramertj
Add Pin::{into_inner,into_inner_unchecked}
These functions are useful for unsafe code that needs to temporarily pull smart pointers out of the `Pin`, e.g. [the change that inspired them](https://github.com/Nemo157/futures-rs/commit/b4361780faf764c7cb046ed75f863a6fcfd44800#diff-1a4e0ba4d1b539412ca576411ec6c7c2R258) is taking a `Pin<Box<dyn Future>>`, turning it into a `*mut dyn Future` via `Box::into_raw(unsafe { Pin::into_inner_unchecked(pin) })` then later dropping this via `drop(Pin::from(Box::from_raw(ptr)))`. This can be accomplished today via `{ let ptr = unsafe { Pin::get_unchecked_mut(pin.as_mut()) } as *mut dyn Future; mem::forget(pin); ptr }`, but this is far more complicated and loses out on the symmetry of using `Box::into_raw` and `Box::from_raw`.
I'll extend the documentation on what guarantees `into_inner_unchecked` needs to uphold once I get some feedback on whether this API is wanted or not.
r? @withoutboats
Diffstat (limited to 'src/libstd/sys')
0 files changed, 0 insertions, 0 deletions
