config-rs
config-rs copied to clipboard
Are defaults for an array of tables supported?
Is it possible to set defaults for an array of tables, so that omitted values are automatically populated? I've checked through the examples and documentation and I can't find a clear answer.
Example:
[MyTableDefaults]
item1 = false
item2 = false
item3 = false
item4 = false
item5 = false
[[MyTable]]
item1 = true
item2 = true
[[MyTable]]
item3 = true
item4 = true
After merging the effective configuration would be:
[[MyTable]]
item1 = true
item2 = true
item3 = false
item4 = false
item5 = false
[[MyTable]]
item1 = false
item2 = false
item3 = true
item4 = true
item5 = false
Not sure whether this is still relevant, but I guess that's rather hard to achieve with the current implementation of the crate and maybe not even possible at all.
I believe it is still beneficial, but I don't know about absolute necessity. I don't remember much about the implementation anymore or how feasible it would be.
What I do remember is my workaround. I just use another function to copy the values from MyTableDefaults to each MyTable instance when they don't exist. It's not a very clean way of doing it, but it accomplishes my needs.