-
Notifications
You must be signed in to change notification settings - Fork 13
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
Adding CustomFn layer #34
Conversation
…all-features` test will pass
…sures) can provide a values. This is useful to support additional data sources, for example a database or an unsupported file format, e.g. hjson
Here is a code excerpt from the test, to see the usage: #[config]
#[derive(Debug, Default)]
struct TestCfg {
test: String,
another: usize,
}
std::env::set_var("ANOTHER", "5");
let func = || {
to_value(TestCfg{test: "from func".to_string(), another: 25}).unwrap()
};
let prio = vec![Layer::CustomFn(func.into()), Layer::Env(None)];
let config = TestCfg::with_layers(&prio).unwrap();
assert_eq!(config.test, String::from("from func"));
assert_eq!(config.another, 5usize); |
…irement on the closure makes an Fn version no better than a static fn. Fixing a wrong doc comment
Hey @luketpeterson it looks great ! Thank you ! Could you just document it in the README here to let users know that layer exists. Thanks a lot |
(tests are failing too) |
The test issue is that the set of features enabled by the github action (equivalent to running However, the same situation exists for nearly all the optional features. For example, invoking |
I could conditionally exclude the test (as is done in |
…regardless of which combination of features are enabled
Seems the way I (and the tests/default.rs) file were doing conditional compilation was just broken. I fixed that, and added feature gates to all tests, so now |
Synchronizing 3 copies of README.md in the repo
Committed README updates, also synchronizing README content across sub-crates within the repo. |
Thanks a lot. Released on |
Adding CustomFn layer, where any Fn type, (function or immutable closure) can provide config values.
This is useful to support additional data sources, for example to get values from a database or from an unsupported file format, e.g. hjson (https://crates.io/crates/deser-hjson)
Thank you.