Skip to content
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

WIP: Infer default for Option fields #163

Closed
wants to merge 1 commit into from

Conversation

TedDriggs
Copy link
Owner

Related to #161

@@ -7,6 +7,18 @@ use syn::{Ident, Path, Type};
use crate::codegen::{DefaultExpression, PostfixTransform};
use crate::usage::{self, IdentRefSet, IdentSet, UsesTypeParams};

fn is_option(ty: &Type) -> bool {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is something derive_builder and serde also do. Should it be extracted to be part of darling::util?

@@ -173,7 +197,7 @@ impl<'a> ToTokens for Initializer<'a> {
} else {
quote!(#ident: #ident)
}
} else if let Some(ref expr) = field.default_expression {
} else if let Some(ref expr) = self.option_aware_default() {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we do something here to make spans better?

Base automatically changed from stacked-defaults-tests to master March 9, 2022 15:30
@TedDriggs
Copy link
Owner Author

This has been superseded by #177, which is safer.

@TedDriggs TedDriggs closed this Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant