[pbs-devel] [PATCH proxmox 17/18] acme-api: remove manual implementation of Option::map

Shannon Sterz s.sterz at proxmox.com
Wed Jun 26 13:36:27 CEST 2024


On Wed Jun 26, 2024 at 12:45 PM CEST, Maximiliano Sandoval wrote:
> Fixes the clippy warning:
>
> warning: manual implementation of `Option::map`
>    --> proxmox-acme-api/src/certificate_helpers.rs:346:32
>     |
> 346 |                           } else if let Some(uri) = name.uri() {
>     |  ________________________________^
> 347 | |                             Some(format!("URI: {uri}"))
> 348 | |                         } else {
> 349 | |                             None
> 350 | |                         }
>     | |_________________________^ help: try: `{ name.uri().map(|uri| format!("URI: {uri}")) }`
>     |
>     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_map
>     = note: `#[warn(clippy::manual_map)]` on by default
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
> ---
>  proxmox-acme-api/src/certificate_helpers.rs | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/proxmox-acme-api/src/certificate_helpers.rs b/proxmox-acme-api/src/certificate_helpers.rs
> index dd8385e2..473bd0e1 100644
> --- a/proxmox-acme-api/src/certificate_helpers.rs
> +++ b/proxmox-acme-api/src/certificate_helpers.rs
> @@ -343,11 +343,7 @@ impl CertificateInfo {
>                              Some(format!("IP: {ip:?}"))
>                          } else if let Some(email) = name.email() {
>                              Some(format!("EMAIL: {email}"))
> -                        } else if let Some(uri) = name.uri() {
> -                            Some(format!("URI: {uri}"))
> -                        } else {
> -                            None
> -                        }
> +                        } else { name.uri().map(|uri| format!("URI: {uri}")) }

did you rustfmt this? over here it doesn't like the "single line else"
and imo it looks quite akward

>                      })
>                      .collect()
>              })





More information about the pbs-devel mailing list