Skip to content
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

Allow serde to be turned off without turning off std #60

Merged
merged 1 commit into from
Jun 1, 2019

Conversation

est31
Copy link
Contributor

@est31 est31 commented May 24, 2019

Fixes #59

@pczarn
Copy link
Contributor

pczarn commented Jun 1, 2019

With this change, such code in a downstream Cargo.toml:

bit-vec = { version = "0.6", features = ["serde_std"] }

is exactly equivalent to

bit-vec = { version = "0.6", features = ["serde"] }
serde = "1.0"

Passing a 'serde' feature makes sense only if you intend to depend on it. However, we cannot be sure downstream crates are reasonable.

What's more, serde has the alloc feature, which we must pass, because we use the alloc crate on no_std.

One decent option is to have this

serde_std = ["std", "serde/std"]
serde_no_std = ["serde/alloc"]

Another, more transparent option would be a build script to configure it for us. Unfortunately, this is impossible, build scripts cannot deeply interact with cargo: rust-lang/cargo#5499.

@pczarn
Copy link
Contributor

pczarn commented Jun 1, 2019

Yet another option is to open an issue for Cargo about the semantics of enabling a dependency's feature. We may have an option to say serde/std if serde.

@pczarn pczarn merged commit f7678c2 into contain-rs:master Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

no way to disable serde on 0.6 with stable Rust
2 participants