Repository navigation
Make serde, toml deps optional - #310
Merged
Merged
Conversation
We make `serde` and `toml` dependencies optional, enabled by default, using default features. Config[^1] already allows to configure it programmatically, using the `set_xxx` methods. However, refinery-core (used by refinery crate) uses serde by default to support serialization and deserialization of this type. This is unnecessary if one doesn't need the `refinery-cli` and also configures it programmatically. On top of that, refinery makes the assumption that `Toml` format will be used to deserialize/serialize this type, as toml dependency is used as well in refinery-core by default. Again it's not always the case, this is more related with `refinery-cli`. Let's declare both `serde` and `toml` dependencies as optional, under a feature flag. Apparently, if `toml` dependency is enabled, `serde` should be enabled as well, thus `toml` feature enables `serde` feature automatically. For `refinery-cli`, we just make sure to enable `toml` (and consequently `serde`) feature when using the `refinery` dependency, since it's impossible fo `refinery-cli` to work without these 2 dependencies. However, for `refinery`, we declare them under the default features: they will be enabled by default, unless the host crate specifies `default-features = false`. Fixes rust-db#308. [^1]: https://docs.rs/refinery/latest/refinery/config/struct.Config.html
jxs
approved these changes
Feb 15, 2024
jxs
left a comment
Member
There was a problem hiding this comment.
Thanks for this! ❤️ And I am sorry for the delay reviewing it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
We make
serdeandtomldependencies optional, enabled by default, using default features.Config1 already allows to configure it programmatically, using the
set_xxxmethods. However, refinery-core (used by refinery crate) uses serde by default to support serialization and deserialization of this type. This is unnecessary if one doesn't need therefinery-cliand also configures it programmatically.On top of that, refinery makes the assumption that
Tomlformat will be used to deserialize/serialize this type, as toml dependency is used as well in refinery-core by default. Again it's not always the case, this is more related withrefinery-cli.Let's declare both
serdeandtomldependencies as optional, under a feature flag. Apparently, iftomldependency is enabled,serdeshould be enabled as well, thustomlfeature enablesserdefeature automatically.For
refinery-cli, we just make sure to enabletoml(and consequentlyserde) feature when using therefinerydependency, since it's impossible forefinery-clito work without these 2 dependencies.However, for
refinery, we declare them under the default features: they will be enabled by default, unless the host crate specifiesdefault-features = false.Fixes #308.
Footnotes
https://docs.rs/refinery/latest/refinery/config/struct.Config.html ↩