This repository was archived by the owner on Aug 15, 2021. It is now read-only.
Allow enabling serde/std
without also requiring serde_cbor/std
to be enabled
#198
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
serde_cbor
'sstd
feature must be enabled ifserde/std
is also enabled, even ifserde/std
is enabled separately by another crate somewhere else in the dependency tree.However, this doesn't necessarily need to be the case.
serde
provides aStdError
type in order to get around this (see serde-rs/serde#1620). This is a type provided byserde
as a re-export ofstd::error::Error
whenserde/std
is enabled and as an export of a customserde::std_error::Error
type with the same interface asstd::error::Error
whenserde/std
is not enabled. By conforming toserde::ser::StdError
instead ofstd::error::Error
,serde_cbor
can rely on thestd
/no_std
state ofserde
rather than requiring that both libraries'std
feature be either both enabled or both disabled.This allows
serde_cbor
to be inno_std
even ifserde/std
is enabled. While this might not make a ton of sense at first glance, this change would lead to a much more robust dependency mechanism whenserde
andserde_cbor
are involved, by allowing a crate to depend onserde_cbor
with default features disabled and not have to worry if another crate (maybe even higher up in the dependency graph) enablesserde/std
completely independently. Ideally, the ultimate goal is that features are additive and not dependent on the state of other features laterally in the dependency graph.This PR does 2 things:
serde_cbor::Error
conforms to fromstd::error::Error
toserde::ser::StdError
..travis.yml
to test building withserde/std
enabled andserde_cbor
's default features disabled in order to test that this configuration is buildable.