Add support for no alloc. #31
Merged
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.
I have a no_alloc and no_std use-case, and it's fortunately quite a simple patch to add support for this. I have tested this patch on a target that doesn't have std, and it works like a charm.
By adding the
#[cfg_attr(docsrs, doc(cfg(feature = "alloc")))]attribute to the few things in bitstream-io that can't function without alloc, docs-rs will automatically point out that this is only available with the alloc feature. You can also test this locally by runningRUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc.Additionally, tests now require std so you don't have to muck around with making all of the tests compatible with no_std and especially no_alloc, as per this advice.
This change is also forwards-compatible, so it will only require a minor version bump.
Closes #5