refactor: ModuleConfig: Simplify generated `from_config()` implementations (#775)

We can use `and_then()` to string `Option` values together so that we only need a single `?` assertion. This makes it generally possible to have e.g. `unwrap_or()` at the end.
This commit is contained in:
Tobias Bieniek 2019-12-23 16:12:21 +01:00 committed by Matan Kushner
parent c4ed88952c
commit 9a1569444b
1 changed files with 1 additions and 1 deletions

View File

@ -33,7 +33,7 @@ fn impl_module_config(dinput: DeriveInput) -> proc_macro::TokenStream {
}
};
let new_from_tokens = quote! {
#ident: <#ty>::from_config(config.get(stringify!(#ident))?)?,
#ident: config.get(stringify!(#ident)).and_then(<#ty>::from_config)?,
};
load_tokens = quote! {