Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion crates/bevy_ptr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,10 @@ impl<'a, T, A: IsAligned> MovingPtr<'a, T, A> {
/// - `inner` must have correct provenance to allow read and writes of the pointee type.
/// - The lifetime `'a` must be constrained such that this [`MovingPtr`] will stay valid and nothing
/// else can read or mutate the pointee while this [`MovingPtr`] is live.
/// - This call transfers the right to move out of or drop the pointee to the returned
/// [`MovingPtr`]. Once it has been used (moved out of, dropped, or forgotten), whatever
/// previously owned `inner` must treat it as uninitialized and must not access or drop it
/// as `T` again unless that location is properly reinitialized first.
///
/// [properly aligned]: https://doc.rust-lang.org/std/ptr/index.html#alignment
#[inline]
Expand Down Expand Up @@ -917,7 +921,13 @@ impl<'a, A: IsAligned> PtrMut<'a, A> {
/// Transforms this [`PtrMut`] into an [`OwningPtr`]
///
/// # Safety
/// Must have right to drop or move out of [`PtrMut`].
/// - The caller must have the right to drop or move out of the value behind this
/// [`PtrMut`], i.e. no other code may treat that value as still being owned by
/// whatever `self` was borrowed from.
/// - This call transfers that right to the returned [`OwningPtr`]. Once it has been
/// used (read, dropped, or forgotten), whatever `self` was borrowed from must treat
/// the pointee as uninitialized and must not access or drop it again unless that
/// location is properly reinitialized first.
#[inline]
pub unsafe fn promote(self) -> OwningPtr<'a, A> {
OwningPtr(self.0, PhantomData)
Expand Down Expand Up @@ -1002,6 +1012,10 @@ impl<'a, A: IsAligned> OwningPtr<'a, A> {
/// - `inner` must have correct provenance to allow read and writes of the pointee type.
/// - The lifetime `'a` must be constrained such that this [`OwningPtr`] will stay valid and nothing
/// else can read or mutate the pointee while this [`OwningPtr`] is live.
/// - This call transfers the right to move out of or drop the pointee to the returned
/// [`OwningPtr`]. Once it has been used (read, dropped, or forgotten), whatever
/// previously owned `inner` must treat it as uninitialized and must not access or drop
/// it again unless that location is properly reinitialized first.
///
/// [properly aligned]: https://doc.rust-lang.org/std/ptr/index.html#alignment
#[inline]
Expand Down