-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add support for initialising the pool to some value and allow allocating uninitialized boxes. #7
Conversation
I also fixed some clippy warnings, by adding safety comments to the user facing API: |
Idk about this. In this case, instead of providing a default initial value on the macro, wouldn't it be better to just expose the MaybeUninit cell from the pool when calling Also, maybe this should be behind an optional feature flag. I wouldn't want people using it without great reason. |
I'm going to remove the default initial value again, since |
This is returning a Box that is uninitialized, but there's no type-level indication that it is. For example you can Deref/DerefMut it and obtain a In your example you're doing Due to this, I think the Also, you can already achieve this without API changes by creating a pool of |
That's a good point. |
This might be off topic, but wouldn't this be valid for a byte slice? Since a byte slice can't hold invalid data. |
in the rust abstract machine a byte can have 257 possible values. 0-255 and "uninitialized". Handling uninitialized bytes is UB. You don't get "any random byte", you get actual UB. |
Hi,
this PR adds support for initializing the pool to some default value and allocating uninitialized boxes.
In my project, I want to use this for having a pool of fixed size buffers, for TX/RX of Wi-Fi frames, in my use case, it would incur a significant performance overhead, to clear the buffer.
I also expanded the docs a bit, to help people using this library for the first time.