-
Notifications
You must be signed in to change notification settings - Fork 3
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
Testing OwnedStorage trait, growable AllocVec #5
base: main
Are you sure you want to change the base?
Conversation
03be652
to
dd06f4f
Compare
Hi! Thanks for tackling this, that'll be a huge help. Some remarks:
To be clear, I don't expect you to do the method-specific copy optimizations, the copying strategy in data structures other than Also, it's fine you used rustfmt, but the formatting changes make it kind of annoying to find the semantic changes to review. It's on me for not doing this sooner, but I'll quickly run it myself on the whole code base. If you don't mind starting over from that commit, that would be very nice of you, but I fully understand if you don't want to do that. |
Awesome, I'll rebase to fix the conflicts due to the formatting. Rust analyzer is also having a hissy fit about some of the syntax, I think it might be the For the Replacing |
dd06f4f
to
6071a24
Compare
Actually, it doesn't look like |
Ah, true. I think it's fine to just make it a newtype though. Seems better than introducing another new trait. |
6071a24
to
562f4d9
Compare
I have it implemented using an additional trait at the moment. The nice part about that is that the initializer can be const, although due to other limitations |
8c08435
to
34f442d
Compare
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
Signed-off-by: Andrew Whitehead <[email protected]>
a0ce635
to
dc8d8f9
Compare
I think I'm done with potential updates for now, so I can mark this as ready for review or you can merge in what you like manually. It looks like as of Rust 1.61 the I've added a |
Signed-off-by: Andrew Whitehead <[email protected]>
I've also added an initial implementation of the zeroizing storage wrapper I was talking about: https://github.com/andrewwhitehead/coca-zero |
Hiya, any thoughts on this PR? |
For my needs it's pretty important to support a heap Vec that can reallocate, as well as being able to support either inline or allocated Vecs depending on what features are enabled. I put together this set of changes to test a few updates. I see you've created an issue recently which suggests adding a new GrowableVec type; that could also be supported under this general scheme, leaving AllocVec as constant capacity.
Here, the
OwnedStorage
trait allows fornew
,with_capacity
,Clone
,Default
, andFrom
to be supported for multiple storage types, including custom storage types that might be implemented externally. An interesting example would be a zeroizing buffer, which would have better characteristics than aZeroizing<Vec<T>>
(from the zeroize crate) because that type is not able to account for copies made during reallocations.In order to support
new
forAllocVec
it needs to either define a minimum capacity or behave like the standard Vec and start with no allocation, I chose the second option here. The realloc code would probably need significant work in order to optimize it and handle corner cases.