]> git.proxmox.com Git - proxmox-backup.git/commitdiff
realm sync: replace and_then chain with '?' in lookup closure
authorWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Mar 2023 09:46:02 +0000 (11:46 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Mon, 27 Mar 2023 09:47:26 +0000 (11:47 +0200)
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
src/server/realm_sync_job.rs

index b0b1fbfd332796b433c857f5a930854aa787102f..65cb0db8319b1a86e0f8a2a1ef6b3d72c8f1ab34 100644 (file)
@@ -231,24 +231,19 @@ impl LdapRealmSyncJob {
         existing_user: Option<&User>,
     ) -> User {
         let lookup = |attribute: &str, ldap_attribute: Option<&String>, schema: &'static Schema| {
-            ldap_attribute
-                .and_then(|e| result.attributes.get(e))
-                .and_then(|v| v.get(0))
-                .and_then(|value| {
-                    let schema = schema.unwrap_string_schema();
-
-                    if let Err(e) = schema.check_constraints(value) {
-                        task_warn!(
-                            self.worker,
-                            "{userid}: ignoring attribute `{attribute}`: {e}"
-                        );
-
-                        None
-                    } else {
-                        Some(value)
-                    }
-                })
-                .cloned()
+            let value = result.attributes.get(ldap_attribute?)?.get(0)?;
+            let schema = schema.unwrap_string_schema();
+
+            if let Err(e) = schema.check_constraints(value) {
+                task_warn!(
+                    self.worker,
+                    "{userid}: ignoring attribute `{attribute}`: {e}"
+                );
+
+                None
+            } else {
+                Some(value.clone())
+            }
         };
 
         User {