Open tenuous-guidance opened 1 year ago
This is an interesting case.
So the problem stems broadly from the fact that environment variables can either not exist or be a &str.
JSON for example has the null
value, which would help deal with it here.
I am not sure how to solve it from envious
's side. One thing that should work for you, is if you give it a default that returns a None
?
It looks like it can work with:
#[derive(Debug, Deserialize)]
struct Config {
#[serde(default)]
var: Var,
}
#[derive(Default, Debug, Deserialize)]
struct Var(Option<usize>);
Might be that's the best that can be done.
Consider the following types:
I want to set the
Config
to{ var: Var(None) }
, how do I do so?Options I have tried:
var
(this works withvar: Option<usize>
and so is what I'd expect to work here),var
toNone
,var
to""
(the empty string),var_0
,var_0
toNone
,var_0
to""
(the empty string).Example test case: Dependencies:
Code: