Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #5552 - ehuss:config-serde, r=alexcrichton
Typed Config Access This introduces a new API for accessing config values using serde to automatically convert to a destination type. By itself this shouldn't introduce any behavioral changes (except for some slight wording changes to error messages). However, it unlocks the ability to use richer data types in the future (such as `profile`, or `source`). Example: ```rust let p: Option<TomlProfile> = config.get("profile.dev")?; ``` Supports environment variables when fetching structs or maps. Note that it can support underscores in env var for struct field names, but not maps. So for example, "opt_level" works, but not "serde_json" (example: `CARGO_PROFILE_DEV_OVERRIDES_serde_OPT_LEVEL`). I don't have any ideas for a workaround (though I feel this is an overuse of env vars). It supports environment variables for lists. The value in the env var will get appended to anything in the config. It uses TOML syntax, and currently only supports strings. Example: `CARGO_FOO=['a', 'b']`. I did *not* modify `get_list` to avoid changing behavior, but that can easily be changed.
- Loading branch information