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'sstdfeature must be enabled ifserde/stdis also enabled, even ifserde/stdis enabled separately by another crate somewhere else in the dependency tree.However, this doesn't necessarily need to be the case.
serdeprovides aStdErrortype in order to get around this (see serde-rs/serde#1620). This is a type provided byserdeas a re-export ofstd::error::Errorwhenserde/stdis enabled and as an export of a customserde::std_error::Errortype with the same interface asstd::error::Errorwhenserde/stdis not enabled. By conforming toserde::ser::StdErrorinstead ofstd::error::Error,serde_cborcan rely on thestd/no_stdstate ofserderather than requiring that both libraries'stdfeature be either both enabled or both disabled.This allows
serde_cborto be inno_stdeven ifserde/stdis enabled. While this might not make a ton of sense at first glance, this change would lead to a much more robust dependency mechanism whenserdeandserde_cborare involved, by allowing a crate to depend onserde_cborwith default features disabled and not have to worry if another crate (maybe even higher up in the dependency graph) enablesserde/stdcompletely 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::Errorconforms to fromstd::error::Errortoserde::ser::StdError..travis.ymlto test building withserde/stdenabled andserde_cbor's default features disabled in order to test that this configuration is buildable.