all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Maximiliano Sandoval <m.sandoval@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH backup 2/5] metric_collection: remove redundant map_or
Date: Mon, 13 Jan 2025 14:25:50 +0100	[thread overview]
Message-ID: <20250113132553.435319-2-m.sandoval@proxmox.com> (raw)
In-Reply-To: <20250113132553.435319-1-m.sandoval@proxmox.com>

Fixes:

warning: this `map_or` is redundant
   --> src/server/metric_collection/mod.rs:172:20
    |
172 |                   if config
    |  ____________________^
173 | |                     .get_maintenance_mode()
174 | |                     .map_or(false, |mode| mode.check(Some(Operation::Read)).is_err())
    | |_____________________________________________________________________________________^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_map_or
    = note: `#[warn(clippy::unnecessary_map_or)]` on by default
help: use is_some_and instead
    |
172 ~                 if config
173 +                     .get_maintenance_mode().is_some_and(|mode| mode.check(Some(Operation::Read)).is_err())
    |

Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
 pbs-datastore/src/datastore.rs              | 6 +++---
 src/api2/admin/datastore.rs                 | 2 +-
 src/api2/config/datastore.rs                | 2 +-
 src/api2/config/remote.rs                   | 2 +-
 src/bin/proxmox_backup_debug/inspect.rs     | 2 +-
 src/bin/proxmox_backup_manager/datastore.rs | 2 +-
 src/server/metric_collection/mod.rs         | 2 +-
 7 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 0801b4bf..fd3990d6 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -179,9 +179,9 @@ impl Drop for DataStore {
             let remove_from_cache = last_task
                 && pbs_config::datastore::config()
                     .and_then(|(s, _)| s.lookup::<DataStoreConfig>("datastore", self.name()))
-                    .map_or(false, |c| {
+                    .is_ok_and(|c| {
                         c.get_maintenance_mode()
-                            .map_or(false, |m| m.clear_from_cache())
+                            .is_some_and(|m| m.clear_from_cache())
                     });
 
             if remove_from_cache {
@@ -287,7 +287,7 @@ impl DataStore {
         let datastore: DataStoreConfig = config.lookup("datastore", name)?;
         if datastore
             .get_maintenance_mode()
-            .map_or(false, |m| m.clear_from_cache())
+            .is_some_and(|m| m.clear_from_cache())
         {
             // the datastore drop handler does the checking if tasks are running and clears the
             // cache entry, so we just have to trigger it here
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index c611f593..f5d80d61 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -2601,7 +2601,7 @@ fn do_unmount_device(
         active_operations = task_tracking::get_active_operations(&datastore.name)?;
     }
 
-    if aborted || worker.map_or(false, |w| w.abort_requested()) {
+    if aborted || worker.is_some_and(|w| w.abort_requested()) {
         let _ = expect_maintanance_unmounting(&datastore.name)
             .inspect_err(|e| warn!("maintenance mode was not as expected: {e}"))
             .and_then(|(lock, config)| {
diff --git a/src/api2/config/datastore.rs b/src/api2/config/datastore.rs
index df268161..fe3260f6 100644
--- a/src/api2/config/datastore.rs
+++ b/src/api2/config/datastore.rs
@@ -105,7 +105,7 @@ pub(crate) fn do_create_datastore(
             for file in dir {
                 let name = file?.file_name();
                 let name = name.to_str();
-                if !name.map_or(false, |name| name.starts_with('.') || name == "lost+found") {
+                if !name.is_some_and(|name| name.starts_with('.') || name == "lost+found") {
                     is_empty = false;
                     break;
                 }
diff --git a/src/api2/config/remote.rs b/src/api2/config/remote.rs
index 069aef28..7d5173ef 100644
--- a/src/api2/config/remote.rs
+++ b/src/api2/config/remote.rs
@@ -268,7 +268,7 @@ pub fn delete_remote(name: String, digest: Option<String>) -> Result<(), Error>
 
     let job_list: Vec<SyncJobConfig> = sync_jobs.convert_to_typed_array("sync")?;
     for job in job_list {
-        if job.remote.map_or(false, |id| id == name) {
+        if job.remote.is_some_and(|id| id == name) {
             param_bail!(
                 "name",
                 "remote '{}' is used by sync job '{}' (datastore '{}')",
diff --git a/src/bin/proxmox_backup_debug/inspect.rs b/src/bin/proxmox_backup_debug/inspect.rs
index 9a75bae1..75a36870 100644
--- a/src/bin/proxmox_backup_debug/inspect.rs
+++ b/src/bin/proxmox_backup_debug/inspect.rs
@@ -429,7 +429,7 @@ fn inspect_device(device: String, param: Value) -> Result<(), Error> {
             && entry
                 .file_name()
                 .to_str()
-                .map_or(false, |name| name == ".chunks")
+                .is_some_and(|name| name == ".chunks")
         {
             let store_path = entry
                 .path()
diff --git a/src/bin/proxmox_backup_manager/datastore.rs b/src/bin/proxmox_backup_manager/datastore.rs
index 0918af3a..1922a55a 100644
--- a/src/bin/proxmox_backup_manager/datastore.rs
+++ b/src/bin/proxmox_backup_manager/datastore.rs
@@ -273,7 +273,7 @@ async fn uuid_mount(param: Value, _rpcenv: &mut dyn RpcEnvironment) -> Result<Va
             store
                 .backing_device
                 .clone()
-                .map_or(false, |device| device.eq(&uuid))
+                .is_some_and(|device| device.eq(&uuid))
         })
         .collect();
 
diff --git a/src/server/metric_collection/mod.rs b/src/server/metric_collection/mod.rs
index 2ede8408..daedfb72 100644
--- a/src/server/metric_collection/mod.rs
+++ b/src/server/metric_collection/mod.rs
@@ -171,7 +171,7 @@ fn collect_disk_stats_sync() -> (DiskStat, Vec<DiskStat>) {
             for config in datastore_list {
                 if config
                     .get_maintenance_mode()
-                    .map_or(false, |mode| mode.check(Some(Operation::Read)).is_err())
+                    .is_some_and(|mode| mode.check(Some(Operation::Read)).is_err())
                 {
                     continue;
                 }
-- 
2.39.5



_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel


  reply	other threads:[~2025-01-13 13:26 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-13 13:25 [pbs-devel] [PATCH backup 1/5] backup: remove unneded import Maximiliano Sandoval
2025-01-13 13:25 ` Maximiliano Sandoval [this message]
2025-01-13 13:25 ` [pbs-devel] [PATCH backup 3/5] elide lifetimes when possible Maximiliano Sandoval
2025-01-13 13:25 ` [pbs-devel] [PATCH backup 4/5] sg_pt_changer: remove needless call to as_bytes() Maximiliano Sandoval
2025-01-13 13:25 ` [pbs-devel] [PATCH backup 5/5] replace match statements with ? operator Maximiliano Sandoval
2025-01-14  7:59 ` [pbs-devel] applied: [PATCH backup 1/5] backup: remove unneded import Dietmar Maurer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250113132553.435319-2-m.sandoval@proxmox.com \
    --to=m.sandoval@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal