json now defaults Option<_> to None.#16971
json now defaults Option<_> to None.#16971bors merged 1 commit intorust-lang:masterfrom treeman:json-decode
Conversation
There was a problem hiding this comment.
This is not going to work right if I have a type named Option that is not std::option::Option.
Similarly, it presumably will not work right if I rename Option, using either use std::option::Option as Foo or type Foo = std::option::Option<int>.
There was a problem hiding this comment.
Good point, I totally missed that.
|
I feel like the right approach here really is to be able to provide a default value to use if the field isn't present. This is just another instance of the need to be able to customize deriving. |
|
Note that it is currently possible for decoders to emulate this behavior today, as it's what |
|
I agree @kballard, we need default values. Thanks @alexcrichton, will take a peek. |
|
Reworked the #17089 may enable us to specify default arguments, something like: I still think it's more ergonomic to have |
Resolve tests per file instead of per crate in test explorer Fix part of rust-lang#16827
Closes #12794.