feat: make alloc optional #606
Open
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.
Currently the
no_stdsupport for the crate still depends onalloc. However, this is only required forBytesandBytesMutdata structures and notBufandBufMuttraits or its other impls. This PR makesallocoptional in order to make the crate more suitable for embedded environments.The main benefit of this change is beeing able to depend only on the
BufandBufMuttraits, which is very usefull not only to embedded environments, but also for other crates that would like to use those traits but don't needBytesandBytesMut. I think this would be a good thing, since it encorages everyone to usebytesand reduce the number of parallel implementations of this same concept.As an example usecase,
rust-mavlinkhad to pretty much reimplementBufandBufMutbecause they don't want a hard dependency onalloc.This PR adds a
allocdefault feature that can be disabled if not required. However, maybe it would be better to add aembeddedorno_allocfeature instead, so that it doesn't break any code that depends onbytes. Please let me know what you think of this change.