-
Notifications
You must be signed in to change notification settings - Fork 295
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
feat: make alloc optional #606
base: master
Are you sure you want to change the base?
Conversation
Sorry, but this is a breaking change. Code that previously compiled with no features enabled would break. Unfortunately, we also cannot add a |
Oh, I see. Would it be possible to maybe create a different crate (say we name it |
See #479 for previous discussions. |
Can we finally get that in? Every year I'm starting a new project that would benefit from using From #479 (comment)
I would assume that more than 3 years after v1 release we can allow a major update that would allow more people to finally use this lib. |
The only possible way that this is happening is that we accept the minor breakage. We will not make a bytes v2. |
So what's your opinion on that, in regard to #480 (comment) ? |
I do not really know how many libraries out there specify |
Sorry, I failed to respond to this. We already have std as a default feature, so it's extremely likely that there are users of |
Currently the
no_std
support for the crate still depends onalloc
. However, this is only required forBytes
andBytesMut
data structures and notBuf
andBufMut
traits or its other impls. This PR makesalloc
optional 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
Buf
andBufMut
traits, which is very usefull not only to embedded environments, but also for other crates that would like to use those traits but don't needBytes
andBytesMut
. I think this would be a good thing, since it encorages everyone to usebytes
and reduce the number of parallel implementations of this same concept.As an example usecase,
rust-mavlink
had to pretty much reimplementBuf
andBufMut
because they don't want a hard dependency onalloc
.This PR adds a
alloc
default feature that can be disabled if not required. However, maybe it would be better to add aembedded
orno_alloc
feature instead, so that it doesn't break any code that depends onbytes
. Please let me know what you think of this change.