/// Repairs an instance of `Self` located at `moved` back into a valid state.
///
/// # Safety
///
/// The data referenced by `moved` must have been
///
/// - previously located at `old_address`,
/// - must have been initialized as valid instance of `Self` there and
/// - must have been moved to its new location without modification since then.
unsafe fn repair_moved(old_address: NonNull<Self>, moved: Pin<&mut MaybeUninit<Self>>);
would be potentially helpful as optimisation for reallocating pinning collections.
As I said before, I don't expect this to be currently useful, and also would not currently have a use for it myself.
I just came across it while writing a blog post about pinning and wanted to jot down the idea somewhere since it doesn't fit that text.
The traits in this crate will most likely see a huge boost in helpfulness once specialisation allows them to be default-implemented for T: Unpin. Feel free to ping me when that happens and I should have time to gladly turn this feature into a pull-request (with hopefully better naming-sense, as I'm not sure repair_moved checks out and is consistent with the other traits in the crate).
This isn't currently useful on stable, and likely won't be until https://github.com/rust-lang/rust/issues/32838 (more specifically
Allocator::grow_zeroed
) and https://github.com/rust-lang/rust/issues/31844 (at least#![feature(min_specialization)]
) land, but anunsafe
trait with a function likewould be potentially helpful as optimisation for reallocating pinning collections.
As I said before, I don't expect this to be currently useful, and also would not currently have a use for it myself. I just came across it while writing a blog post about pinning and wanted to jot down the idea somewhere since it doesn't fit that text.
The traits in this crate will most likely see a huge boost in helpfulness once specialisation allows them to be default-implemented for
T: Unpin
. Feel free to ping me when that happens and I should have time to gladly turn this feature into a pull-request (with hopefully better naming-sense, as I'm not surerepair_moved
checks out and is consistent with the other traits in the crate).