access-control/tfa: use ? instead of unnecessary match statements

this makes the code more concise and legible. fixes a clippy lint [1].

[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#question_mark

Signed-off-by: Shannon Sterz <s.sterz@proxmox.com>
This commit is contained in:
Shannon Sterz 2025-03-06 13:43:36 +01:00 committed by Wolfgang Bumiller
parent a318fcedd3
commit 946d95cfcd
2 changed files with 3 additions and 12 deletions

View File

@ -208,10 +208,7 @@ impl AclTree {
let mut node = &self.root;
for outer in path {
for comp in outer.split('/') {
node = match node.children.get(comp) {
Some(n) => n,
None => return None,
};
node = node.children.get(comp)?;
}
}
Some(node)
@ -221,10 +218,7 @@ impl AclTree {
let mut node = &mut self.root;
for outer in path {
for comp in outer.split('/') {
node = match node.children.get_mut(comp) {
Some(n) => n,
None => return None,
};
node = node.children.get_mut(comp)?;
}
}
Some(node)

View File

@ -98,10 +98,7 @@ pub fn list_user_tfa(config: &TfaConfig, userid: &str) -> Result<Vec<TypedTfaInf
///
/// In case this returns `None` a `NOT_FOUND` http error should be returned.
pub fn get_tfa_entry(config: &TfaConfig, userid: &str, id: &str) -> Option<TypedTfaInfo> {
let user_data = match config.users.get(userid) {
Some(u) => u,
None => return None,
};
let user_data = config.users.get(userid)?;
Some({
let res = {