public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new)
@ 2024-06-26 12:43 Maximiliano Sandoval
  2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 02/18] use contains_key instead of .get().is_{some, none}() Maximiliano Sandoval
                   ` (17 more replies)
  0 siblings, 18 replies; 19+ messages in thread
From: Maximiliano Sandoval @ 2024-06-26 12:43 UTC (permalink / raw)
  To: pbs-devel

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 <m.sandoval@proxmox.com>
---
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




^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2024-06-28  9:45 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-26 12:43 [pbs-devel] [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 02/18] use contains_key instead of .get().is_{some, none}() Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 03/18] remove needless borrows Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 04/18] remove unnecesary pub(self) Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 05/18] time-api: remove redundant field names Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 06/18] acme: remove duplicated attribute Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 07/18] acl: remove null pointer cast Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 08/18] use const blocks in thread_local! calls Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 09/18] remove unneeded returns Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 10/18] shared-memory: remove unneeded generic parameter Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 11/18] network-api: remove useless uses of format! Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 12/18] http: remove redundant redefinition of binding Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 13/18] http: remove unnecessary cast Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 14/18] acme: elide explicit lifetimes Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 15/18] acme: derive Default for Status Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 16/18] acl: directly return struct rather than a binding Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 17/18] acme-api: remove manual implementation of Option::map Maximiliano Sandoval
2024-06-26 12:43 ` [pbs-devel] [PATCH proxmox v2 18/18] auth-api: do not clone struct implementing Copy Maximiliano Sandoval
2024-06-28  9:44 ` [pbs-devel] applied-series: [PATCH proxmox v2 01/18] use unwrap_or_default instead of unwrap_or(Vec::new) Wolfgang Bumiller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal