From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ronja.mits.lan by ronja.mits.lan with LMTP id UAu4HgsNfGbcEwAAxxbTJA (envelope-from ); Wed, 26 Jun 2024 14:43:55 +0200 Received: from proxmox-new.maurer-it.com (unknown [192.168.2.33]) by ronja.mits.lan (Postfix) with ESMTPS id 5EF28F6463B; Wed, 26 Jun 2024 14:43:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 41D9F48726; Wed, 26 Jun 2024 14:43:55 +0200 (CEST) Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by proxmox-new.maurer-it.com (Proxmox) with ESMTPS; Wed, 26 Jun 2024 14:43:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 91885A4C; Wed, 26 Jun 2024 14:43:51 +0200 (CEST) From: Maximiliano Sandoval To: pbs-devel@lists.proxmox.com Date: Wed, 26 Jun 2024 14:43:29 +0200 Message-Id: <20240626124346.531790-1-m.sandoval@proxmox.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Subject: [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Backup Server development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pbs-devel-bounces@lists.proxmox.com Sender: "pbs-devel" X-SPAM-LEVEL: Spam detection results: 0 DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods MAILING_LIST_MULTI -2 Multiple indicators imply a widely-seen list manager RAZOR2_CF_RANGE_51_100 2.43 Razor2 gives confidence level above 50% RAZOR2_CHECK 1.729 Listed in Razor2 (http://razor.sf.net/) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Fixes the clippy warning: warning: use of `unwrap_or_else` to construct default value --> proxmox-tfa/src/api/mod.rs:1355:43 | 1355 | |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new), | ^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `unwrap_or_default()` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unwrap_or_default = note: `#[warn(clippy::unwrap_or_default)]` on by default Signed-off-by: Maximiliano Sandoval --- Differences from v1: - run rustfmt - add missing negation from going to get().is_none() to contains_key() proxmox-tfa/src/api/mod.rs | 2 +- proxmox-tfa/src/api/serde_tools.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/proxmox-tfa/src/api/mod.rs b/proxmox-tfa/src/api/mod.rs index f7aeea5a..16444f17 100644 --- a/proxmox-tfa/src/api/mod.rs +++ b/proxmox-tfa/src/api/mod.rs @@ -1352,7 +1352,7 @@ where let expire_before = proxmox_time::epoch_i64() - CHALLENGE_TIMEOUT_SECS; deserializer.deserialize_seq(serde_tools::fold( "a challenge entry", - |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new), + |cap| cap.map(Vec::with_capacity).unwrap_or_default(), move |out, reg: T| { if !reg.is_expired(expire_before) { out.push(reg); diff --git a/proxmox-tfa/src/api/serde_tools.rs b/proxmox-tfa/src/api/serde_tools.rs index 8fbe0fc2..206128bd 100644 --- a/proxmox-tfa/src/api/serde_tools.rs +++ b/proxmox-tfa/src/api/serde_tools.rs @@ -83,7 +83,7 @@ where /// { /// deserializer.deserialize_seq(proxmox_serde::fold( /// "a sequence of integers", -/// |cap| cap.map(Vec::with_capacity).unwrap_or_else(Vec::new), +/// |cap| cap.map(Vec::with_capacity).unwrap_or_default(), /// |out, num: u64| { /// if num != 4 { /// out.push(num.to_string()); -- 2.39.2 _______________________________________________ pbs-devel mailing list pbs-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel