Add reserve
ergonomic wrappers for split_at_mut
and array_mut_ref
#10
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These are wrappers for combinations of
slice::split_at
orslice::split_at_mut
witharray_ref
andarray_mut_ref
respectively, that simplify handling a variety of references into a slice. In essence, they use a call tomem::replace
to keep the borrow checker happy while doing roughly this :These functions are handy if you need to borrow slices from binary data, put them into structs of mutable references, and manipulate them. I donno if they really belong in this crate, but it seemed like plausible place. There are only doc tests right now.
I donno if the name
reserve
is really ideal either. We could rename these toprefix_*
andpostfix_*
or something. I do not use thereserve_tail
forms anywhere yet myself, so I kept the name reserve.