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

Use MaybeUninit in the return type for [try_]alloc_layout #93

Open
fitzgen opened this issue Jan 22, 2021 · 2 comments
Open

Use MaybeUninit in the return type for [try_]alloc_layout #93

fitzgen opened this issue Jan 22, 2021 · 2 comments

Comments

@fitzgen
Copy link
Owner

fitzgen commented Jan 22, 2021

MaybeUninit wasn't stable when these APIs were added. Now it is.

Note that this is a breaking change and will require a version bump.

@rtfeldman
Copy link
Contributor

rtfeldman commented Sep 5, 2023

I'd be happy to implement this! To clarify, is the idea to have the return type for those two functions use &[MaybeUninit<u8>] instead of NonNull<u8>?

That makes more sense to me than MaybeUninit<&[u8]> because the slice's metadata is initialized (e.g. its length is available without unsafe), it's just the bytes that aren't.

@fitzgen
Copy link
Owner Author

fitzgen commented Sep 13, 2023

I'd be happy to implement this! To clarify, is the idea to have the return type for those two functions use &[MaybeUninit<u8>] instead of NonNull<u8>?

That makes more sense to me than MaybeUninit<&[u8]> because the slice's metadata is initialized (e.g. its length is available without unsafe), it's just the bytes that aren't.

That is correct.

However I don't think we actually want to implement this until we're ready for a breaking change to bumpalo, which probably won't be until std supports custom allocators or some other really well motivated reason.

We would also want to double check that this change doesn't regress the performance of allocation, since all the allocation APIs are built on top of these methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants