Auto merge of #5552 - ehuss:config-serde, r=alexcrichton
authorbors <bors@rust-lang.org>
Wed, 30 May 2018 20:12:02 +0000 (20:12 +0000)
committerbors <bors@rust-lang.org>
Wed, 30 May 2018 20:12:02 +0000 (20:12 +0000)
commit5fc6eadc362e52c885a8cf24b924be53467fe65f
treea47d5f622291691e198dcbf8c149df68201a8c9f
parenta5b13e82db645bb5af33fc59d67da63ea30a17af
parentb3db164b9294b7a085553dd70ceeedcebfcd733d
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.