Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace IsAligned marker struct with const generic in bevy_ptr #18085

Closed
mysteriouslyseeing opened this issue Feb 28, 2025 · 0 comments
Closed
Labels
A-Pointers Relating to Bevy pointer abstractions C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples

Comments

@mysteriouslyseeing
Copy link
Contributor

What problem does this solve or what need does it fill?

The Ptr, PtrMut and OwningPtr types use a marker struct to indicate whether the pointer is aligned. It may be more appropriate to use a const generic parameter instead.

What solution would you like?

Replace the Ptr, PtrMut and OwningPtr declarations with variations on the following:

pub struct Ptr<'a, const IS_ALIGNED: bool = true>(NonNull<u8>, PhantomData<&'a u8>);

Perhaps also replace use of the boolean literals true and false with ALIGNED and UNALIGNED for readability (Ptr::<ALIGNED> rather than Ptr::<true>)

pub const ALIGNED: bool = true;
pub const UNALIGNED: bool = false;

Additional context

Supercedes #17988 and thus #18042

@mysteriouslyseeing mysteriouslyseeing added C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 28, 2025
@MrGVSV MrGVSV added C-Usability A targeted quality-of-life change that makes Bevy easier to use A-Pointers Relating to Bevy pointer abstractions D-Straightforward Simple bug fixes and API improvements, docs, test and examples and removed C-Feature A new feature, making something new possible S-Needs-Triage This issue needs to be labelled labels Feb 28, 2025
@alice-i-cecile alice-i-cecile closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Pointers Relating to Bevy pointer abstractions C-Usability A targeted quality-of-life change that makes Bevy easier to use D-Straightforward Simple bug fixes and API improvements, docs, test and examples
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants