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

Use the new feature resolver #551

Merged
merged 1 commit into from
Sep 22, 2022
Merged

Use the new feature resolver #551

merged 1 commit into from
Sep 22, 2022

Conversation

c410-f3r
Copy link
Contributor

Previous behaviour

The usage of an optional feature always pulls the optional dependencies listed in the same feature even if these dependencies weren't explicitly required, which is generally undesired, surprising and slower.

[dependencies]
rgb = { default-features = false, optional = true, version = "0.8" }
serde = { default-features = false, optional = true, version = "1.0" }

[features]
# `with-serde` will always bring `serde` as well as `rgb`
with-serde = ["rgb/serde", "serde"]

Current behaviour

With the new "weak dependency" feature, optional dependencies won't be automatically pulled effectively solving the above problem.

[dependencies]
rgb = { default-features = false, optional = true, version = "0.8" }
serde = { default-features = false, optional = true, version = "1.0" }

[features]
# `rgb` won't be included unless the `rgb` feature is required
with-serde = ["rgb?/serde", "serde"]

Future behaviour

The "name-spaced dependency" feature enables the listing of optional features using the name of any optional dependency, so, instead of creating features with prefixes, suffices or funny names to avoid overlapping, it will be possible to group related stuff in intuitive names.

[dependencies]
rgb = { default-features = false, optional = true, version = "0.8" }
serde = { default-features = false, optional = true, version = "1.0" }

[features]
# `serde` can now be used as a feature with `dep:`
serde = ["rgb?/serde", "dep:serde"]

@c410-f3r
Copy link
Contributor Author

I personally prefer to declare all optional dependencies with dep: and then #[features] foo = ["dep:foo"] to avoid confusing with the older resolver but in this PR only the minimal has been modified.

@paupino
Copy link
Owner

paupino commented Sep 22, 2022

This looks good. Because it relies on 1.60 I want to make sure I hold off on releasing an entirely new version until 1.64 is released though that should be just around the corner given the 6 week release cycles - perhaps by tomorrow?

@paupino paupino merged commit bdc7043 into paupino:master Sep 22, 2022
@paupino
Copy link
Owner

paupino commented Sep 22, 2022

I also like the explicit dep: syntax too! It has been a real pain trying to avoid feature/dependency conflicts to date 😂

@paupino
Copy link
Owner

paupino commented Sep 22, 2022

Also, thank you @c410-f3r once again for your help with this library!

@c410-f3r
Copy link
Contributor Author

Yeap, today is the day for 1.64.

Thank you @paupino for accepting PRs, maintaining this crate and issuing releases in a regular basis. These efforts are commendable because it is not rare to see open source projects that get stuck over time.

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.

None yet

2 participants