]> git.proxmox.com Git - proxmox-backup.git/commitdiff
Userid: simplify comparison with str
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Thu, 8 Oct 2020 13:37:18 +0000 (15:37 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Thu, 8 Oct 2020 13:56:57 +0000 (15:56 +0200)
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
src/api2/types/userid.rs

index 3001b1d93656642a7d7bccfca10a9ccdfb888447..f0a61031d145dd87c526a6ff2d408f61d111bac8 100644 (file)
@@ -397,10 +397,7 @@ impl TryFrom<String> for Userid {
 
 impl PartialEq<str> for Userid {
     fn eq(&self, rhs: &str) -> bool {
-        rhs.len() > self.name_len + 2 // make sure range access below is allowed
-        && rhs.starts_with(self.name().as_str())
-        && rhs.as_bytes()[self.name_len] == b'@'
-        && &rhs[(self.name_len + 1)..] == self.realm().as_str()
+        self.data == *rhs
     }
 }