Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
623935c
Introduce MovingPtr
james7132 Sep 5, 2025
a33001c
Apply suggestions from code review
james7132 Sep 5, 2025
0e04b09
Provide doc tests, better safety comments, and use associated functio…
james7132 Sep 5, 2025
8eb4823
Fix typo.
james7132 Sep 5, 2025
d8add27
Add missing safety comment
james7132 Sep 5, 2025
a9d7333
Update alignment comments
james7132 Sep 5, 2025
40531b3
Provide links to alignment docs
james7132 Sep 5, 2025
c5418ce
Add MovingPtr to the README
james7132 Sep 5, 2025
6c908a4
Markdown formatting
james7132 Sep 5, 2025
75e1082
Add an option to create a MovingPtr from a &mut MaybeUninit<T>
james7132 Sep 5, 2025
3a609be
Fix docs links
james7132 Sep 5, 2025
d88a9bf
Cleanup
james7132 Sep 5, 2025
8b5dd49
Merge branch 'main' into moving-ptr
james7132 Sep 5, 2025
8b16166
Docs fix
james7132 Sep 5, 2025
e39bc5f
Typo
james7132 Sep 5, 2025
a350b2d
Avoid leaking in TryFrom impl
james7132 Sep 5, 2025
a446641
typo
james7132 Sep 5, 2025
52904d7
Add a conversion from OwningPtr to MovingPtr
james7132 Sep 5, 2025
d0a9edd
drop_in_place docs
james7132 Sep 5, 2025
833a8a9
Add a safe assign_to alternative to write_to
james7132 Sep 5, 2025
a300c72
Add deconstruct_moving_ptr
james7132 Sep 6, 2025
5cc6fc9
Tuple
james7132 Sep 6, 2025
4e2a1c8
Remove unnecesary unsafe block
james7132 Sep 6, 2025
32cce6f
Merge branch 'main' into moving-ptr
james7132 Sep 6, 2025
ba12eaf
Fix doc links
james7132 Sep 6, 2025
6206fb4
Don't repeat
james7132 Sep 6, 2025
12f9094
Replace make_internal with from_value
james7132 Sep 7, 2025
9ce69b5
Merge branch 'main' into moving-ptr
james7132 Sep 7, 2025
6bb2fa3
size -> count
james7132 Sep 7, 2025
abc82c0
Merge branch 'main' into moving-ptr
alice-i-cecile Sep 7, 2025
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
6 changes: 6 additions & 0 deletions crates/bevy_ptr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ multiple instances to collectively own the data it points to, and as a result, f
|---------------------|-----------|-------|--------------|-------|--------|----------------|------------------|
|`ConstNonNull<T>` |No |No |Yes |No |Yes |No |Yes |
|`ThinSlicePtr<'a, T>`|Yes |No |Yes |Yes |Yes |Yes |Yes |
|`MovingPtr<'a, T>` |Yes |Yes |Yes |Maybe |Yes |Yes |Yes |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The names OwningPtr and MovingPtr make sense individually, but together they don't make it immediately clear which one is typed and which one isn't. I don't have any better suggestions, though!

|`OwningPtr<'a>` |Yes |Yes |No |Maybe |Yes |Yes |No |
|`Ptr<'a>` |Yes |No |No |Maybe |Yes |No |No |
|`PtrMut<'a>` |Yes |Yes |No |Maybe |Yes |Yes |No |
Expand All @@ -109,3 +110,8 @@ accessing elements in the slice is `unsafe`. In debug builds, the length is incl
`OwningPtr<'a>`, `Ptr<'a>`, and `PtrMut<'a>` act like `NonNull<()>`, but attempts to restore much of the safety guarantees of `Unique<T>`, `&T`, and `&mut T`.
They allow working with heterogenous type erased storage (i.e. ECS tables, typemaps) without the overhead of dynamic dispatch in a manner that progressively
translates back to safe borrows. These types also support optional alignment requirements at a type level, and will verify it on dereference in debug builds.

`MovingPtr<'a, T>` is like a lifetimed-`Box<T>` or a typed `OwningPtr<'a>` made for cheaply moving potentially large values around in memory.
It's a pointer that owns the value it points to but does not own the allocation. If dropped, it will drop the value it points to, just as
if you dropped a value of the inner type but won't deallocate the allocation where the value lived in. It provides a number of methods for moving the value
into another location in memory, including options for partial or deconstructive moves.
Loading
Loading