Use try operator for Option more

next
Jonas Platte 2021-06-17 20:37:07 +02:00
parent f3e630c064
commit b291e76572
No known key found for this signature in database
GPG Key ID: CC154DE0E30B7C67
3 changed files with 4 additions and 24 deletions

View File

@ -97,12 +97,7 @@ pub async fn get_alias_helper(
.map_or_else(Vec::new, |aliases| { .map_or_else(Vec::new, |aliases| {
aliases aliases
.iter() .iter()
.filter_map(|aliases| { .filter_map(|aliases| Regex::new(aliases.get("regex")?.as_str()?).ok())
aliases
.get("regex")
.and_then(|regex| regex.as_str())
.and_then(|regex| Regex::new(regex).ok())
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
}); });

View File

@ -1361,12 +1361,7 @@ impl Rooms {
.map_or_else(Vec::new, |users| { .map_or_else(Vec::new, |users| {
users users
.iter() .iter()
.filter_map(|users| { .filter_map(|users| Regex::new(users.get("regex")?.as_str()?).ok())
users
.get("regex")
.and_then(|regex| regex.as_str())
.and_then(|regex| Regex::new(regex).ok())
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
}); });
let aliases = namespaces let aliases = namespaces
@ -1375,12 +1370,7 @@ impl Rooms {
.map_or_else(Vec::new, |aliases| { .map_or_else(Vec::new, |aliases| {
aliases aliases
.iter() .iter()
.filter_map(|aliases| { .filter_map(|aliases| Regex::new(aliases.get("regex")?.as_str()?).ok())
aliases
.get("regex")
.and_then(|regex| regex.as_str())
.and_then(|regex| Regex::new(regex).ok())
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
}); });
let rooms = namespaces let rooms = namespaces

View File

@ -1691,12 +1691,7 @@ pub(crate) fn append_incoming_pdu(
.map_or_else(Vec::new, |users| { .map_or_else(Vec::new, |users| {
users users
.iter() .iter()
.filter_map(|users| { .filter_map(|users| Regex::new(users.get("regex")?.as_str()?).ok())
users
.get("regex")
.and_then(|regex| regex.as_str())
.and_then(|regex| Regex::new(regex).ok())
})
.collect::<Vec<_>>() .collect::<Vec<_>>()
}); });
let aliases = namespaces let aliases = namespaces