This is to make adding fields to those structs a non-breaking change.
This unfortunately means that users cannot use the struct initializer
syntax anymore. They have to create a mutable variable and change fields
that way. It's slightly annoying, but I think we want `non_exhaustive`.
Also, there are multiple discussions and pre-RFCs for letting Rust allow
the struct initializer syntax when the type implements `Default`. So
maybe this will improve in the future.
This gets rid of a lot of duplicated logic that was previously
copy&pasted. This commit alos:
- Makes it easier to implement new formats
- Gets rid of a few bugs
- Makes the system more flexible (more options)
- Adds a lot of additional tests
Regarding nested fields: I cannot imagine a situation where that
distinction is useful. Also, specifying an empty nested object looks
stupid in TOML and YAML anyway.
Regarding default fields: If there is a default value, then the field
should not be declared as optional to begin with.