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.
Makes the crate unconditionally
#![no_std]
and pulls inextern crate alloc
andextern crate std
as configured by feature flags (std
remains the default).All functionality other than
HeaderMap::try_from::<std::collections::HashMap>
can be implemented withalloc
+hashbrown
, so this crate should be usable on embedded platforms functionally as-is.Without
alloc
, we can only provide support for methods, status codes, versions, and standard header names, a pretty limited subset of functionality, though still useful for consistent types in contexts without allocation. I'd be very interested in working on a future PR addingheapless
support (if the maintainers are amenable) so that most of this crate can work without an allocator, but that won't make it into this PR.Worth noting that #732 exists -- not aiming to tread on toes, I just wasn't aware of it until I went to submit this.
All tests pass with all combinations of feature flags.
Compatibility / substantive changes
Almost all the changes in this PR are mechanical renamings of
std
imports tocore
oralloc
. The next most common changes are adding#[cfg(feature = "alloc")]
where appropriate.There are no functional or compatibility changes with the
std
feature flag, and dropping toalloc
fromstd
only removes theHeaderMap::try_from<std::collections::HashMap>
impl (while one is still provided forhashbrown::HashMap
andalloc::collections::BTreeMap
).Some code changes were necessary to support non-
alloc
environments -- these are inheader/name.rs
,method.rs
, anduri/scheme.rs
: