What is your solution for representing the difference between
{"foo": null} and {}
Because they are different, right?
{"foo": null} and {}
Because they are different, right?
Option<Option<String>>
Here, "None" means "no value specified", and "Some(None)" means "a value is specified, and that value is null." And "Some(Some(my_string))" means the value is "my_string".There are other ways to represent this in Rust, some of which might be clearer. This representation seems to be used most often if you have a type "MyType", and you want to automatically derive a type "MyTypePatch" using a macro.
What I'm wondering is how people who have an issue with different representations of absence would approach (or avoid?) situations requiring them.
Ideally you can force the use of the discriminator… but that depends on your type system
Where the "double absence" issue comes up in practice, it's usually in a context where it does make sense to represent and handle the first type of absence separately from the second type.