[pbs-devel] [PATCH proxmox-backup v2 5/8] datastore: fix clippy warning to use ? on option

Christian Ebner c.ebner at proxmox.com
Wed Jul 30 09:57:47 CEST 2025


As cargo clippy suggests, simple unwrapping of an Option value with
early return if None can be achieved using the question mark syntax.

Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
Reviewed-by: Lukas Wagner <l.wagner at proxmox.com>
Tested-by: Lukas Wagner <l.wagner at proxmox.com>
---
changes since version 1:
 - no changes

 pbs-datastore/src/datastore.rs | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/pbs-datastore/src/datastore.rs b/pbs-datastore/src/datastore.rs
index 3b91a3583..a6849ecf4 100644
--- a/pbs-datastore/src/datastore.rs
+++ b/pbs-datastore/src/datastore.rs
@@ -1835,11 +1835,8 @@ impl DataStore {
     // Check and generate a chunk path from given object key
     fn chunk_path_from_object_key(&self, object_key: &S3ObjectKey) -> Option<(PathBuf, [u8; 32])> {
         // Check object is actually a chunk
-        let digest = match Path::new::<str>(object_key).file_name() {
-            Some(file_name) => file_name,
-            // should never be the case as objects will have a filename
-            None => return None,
-        };
+        // file_name() should always be Some, as objects will have a filename
+        let digest = Path::new::<str>(object_key).file_name()?;
         let bytes = digest.as_bytes();
         if bytes.len() != 64 && bytes.len() != 64 + ".0.bad".len() {
             return None;
-- 
2.47.2





More information about the pbs-devel mailing list