Userid: fix borrow/deref recursion

not triggered by any current code, but this would lead to a stack
exhaustion since borrow would call deref which would call borrow again..

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

View File

@ -131,13 +131,13 @@ impl std::ops::Deref for Username {
impl Borrow<UsernameRef> for Username { impl Borrow<UsernameRef> for Username {
fn borrow(&self) -> &UsernameRef { fn borrow(&self) -> &UsernameRef {
UsernameRef::new(self.as_str()) UsernameRef::new(self.0.as_str())
} }
} }
impl AsRef<UsernameRef> for Username { impl AsRef<UsernameRef> for Username {
fn as_ref(&self) -> &UsernameRef { fn as_ref(&self) -> &UsernameRef {
UsernameRef::new(self.as_str()) self.borrow()
} }
} }
@ -204,13 +204,13 @@ impl std::ops::Deref for Realm {
impl Borrow<RealmRef> for Realm { impl Borrow<RealmRef> for Realm {
fn borrow(&self) -> &RealmRef { fn borrow(&self) -> &RealmRef {
RealmRef::new(self.as_str()) RealmRef::new(self.0.as_str())
} }
} }
impl AsRef<RealmRef> for Realm { impl AsRef<RealmRef> for Realm {
fn as_ref(&self) -> &RealmRef { fn as_ref(&self) -> &RealmRef {
RealmRef::new(self.as_str()) self.borrow()
} }
} }