Userid: simplify comparison with str

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
This commit is contained in:
Fabian Grünbichler 2020-10-08 15:37:18 +02:00 committed by Dietmar Maurer
parent 9a75eb11cb
commit 0b3dc8ed8c
1 changed files with 1 additions and 4 deletions

View 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
}
}