-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
json now defaults Option<_> to None. #16971
Conversation
match def.fields[index].node.ty.node { | ||
TyPath(ref path, _, _) => { | ||
match path.segments.as_slice().get(0) { | ||
Some(x) => x.identifier == token::str_to_ident("Option"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.