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

Make config vectors optional. #801

Merged
merged 1 commit into from
Jun 15, 2022
Merged

Conversation

Alexhuszagh
Copy link
Contributor

Allows us to differentiate between an empty array and an array that was not provided when merging config files.

#754 (comment)

Required for #754.

@Alexhuszagh Alexhuszagh added the no changelog A valid PR without changelog (no-changelog) label Jun 15, 2022
@Alexhuszagh Alexhuszagh requested a review from a team as a code owner June 15, 2022 18:04
@Alexhuszagh
Copy link
Contributor Author

If we use optional variables for config options, then this is required for us to be able to differentiate if a variable is provided and empty, or simply not provided.

For example, if we have:

[build.env]
passthrough = []

We currently cannot differentiate it from:

[build.env]

When merging, this means we do not know if we need to overwrite the value, or not. What this does is it changes all Vec<String> variables in the config file to Option<Vec<String>>, which then us to differentiate the two when merging config files.

src/cross_toml.rs Outdated Show resolved Hide resolved
src/cross_toml.rs Outdated Show resolved Hide resolved
@Alexhuszagh
Copy link
Contributor Author

Both resolved, I made it so there's an if let Some(Some(..)) = ..., which seems to have worked better than I imagined it to.

src/config.rs Outdated Show resolved Hide resolved
Allows us to differentiate between an empty array and an array that was
not provided when merging config files.

cross-rs#754 (comment)

Required for cross-rs#754.
Copy link
Member

@Emilgardis Emilgardis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

@bors
Copy link
Contributor

bors bot commented Jun 15, 2022

Build succeeded:

@bors bors bot merged commit d6d9e66 into cross-rs:main Jun 15, 2022
@Emilgardis Emilgardis added this to the v0.2.2 milestone Jun 16, 2022
@Alexhuszagh Alexhuszagh deleted the config_array branch June 23, 2022 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no changelog A valid PR without changelog (no-changelog)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants