diff options
author | Tobias Bieniek <tobias.bieniek@gmail.com> | 2019-12-23 16:12:21 +0100 |
---|---|---|
committer | Matan Kushner <hello@matchai.me> | 2019-12-23 10:12:21 -0500 |
commit | 9a1569444b0c7b7a605c5fda9a4dba478f59daa2 (patch) | |
tree | 7651124a1a619992c71e7537ceb23bd5cb72c081 /starship_module_config_derive | |
parent | c4ed88952c6e1011748409f72ba1a9ebdb1f9139 (diff) |
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.
Diffstat (limited to 'starship_module_config_derive')
-rw-r--r-- | starship_module_config_derive/src/lib.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/starship_module_config_derive/src/lib.rs b/starship_module_config_derive/src/lib.rs index eeddf5a8b..db2e275eb 100644 --- a/starship_module_config_derive/src/lib.rs +++ b/starship_module_config_derive/src/lib.rs @@ -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! { |