[pbs-devel] applied-seires: [PATCH proxmox 10/10] apt: repositories: remove unnecessary if-let in iterator
Fabian Grünbichler
f.gruenbichler at proxmox.com
Tue Dec 3 14:30:25 CET 2024
with a small follow-up folded into this patch, using `into_values()` instead of `values().copied()`
On December 3, 2024 11:20 am, Maximiliano Sandoval wrote:
> Fixes the manual_flatten clippy lint:
>
> ```
> warning: unnecessary `if let` since only the `Some` variant of the iterator element is used
> --> proxmox-apt/src/repositories/mod.rs:40:5
> |
> 40 | for digest in digests.values() {
> | ^ ---------------- help: try: `digests.values().copied().flatten()`
> | _____|
> | |
> 41 | | if let Some(digest) = digest {
> 42 | | common_raw.extend_from_slice(&digest[..]);
> 43 | | }
> 44 | | }
> | |_____^
> |
> help: ...and remove the `if let` statement in the for loop
> --> proxmox-apt/src/repositories/mod.rs:41:9
> |
> 41 | / if let Some(digest) = digest {
> 42 | | common_raw.extend_from_slice(&digest[..]);
> 43 | | }
> | |_________^
> = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
> = note: `#[warn(clippy::manual_flatten)]` on by default
> ```
>
> Signed-off-by: Maximiliano Sandoval <m.sandoval at proxmox.com>
> ---
> proxmox-apt/src/repositories/mod.rs | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/proxmox-apt/src/repositories/mod.rs b/proxmox-apt/src/repositories/mod.rs
> index 4c954668..b688f66e 100644
> --- a/proxmox-apt/src/repositories/mod.rs
> +++ b/proxmox-apt/src/repositories/mod.rs
> @@ -37,10 +37,8 @@ fn common_digest(files: &[APTRepositoryFile]) -> ConfigDigest {
> }
>
> let mut common_raw = Vec::<u8>::with_capacity(digests.len() * 32);
> - for digest in digests.values() {
> - if let Some(digest) = digest {
> - common_raw.extend_from_slice(&digest[..]);
> - }
> + for digest in digests.values().copied().flatten() {
> + common_raw.extend_from_slice(&digest[..]);
> }
>
> ConfigDigest::from_slice(&common_raw[..])
> --
> 2.39.5
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
More information about the pbs-devel
mailing list