fix new lints; clippy::unnecessary-map-or

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-11-28 23:33:33 +00:00
parent 2a9bb1ce11
commit 58be22e695
9 changed files with 10 additions and 17 deletions

View file

@ -54,7 +54,7 @@ impl LogLevelReloadHandles {
.lock()
.expect("locked")
.iter()
.filter(|(name, _)| names.map_or(false, |names| names.contains(&name.as_str())))
.filter(|(name, _)| names.is_some_and(|names| names.contains(&name.as_str())))
.for_each(|(_, handle)| {
_ = handle.reload(new_value.clone()).or_else(error::else_log);
});

View file

@ -58,8 +58,5 @@ pub unsafe fn current_exe() -> Result<std::path::PathBuf> {
/// accurate on all platforms; defaults to false.
#[must_use]
pub fn current_exe_deleted() -> bool {
std::env::current_exe().map_or(false, |exe| {
exe.to_str()
.map_or(false, |exe| exe.ends_with(" (deleted)"))
})
std::env::current_exe().is_ok_and(|exe| exe.to_str().is_some_and(|exe| exe.ends_with(" (deleted)")))
}

View file

@ -112,7 +112,7 @@ async fn handle_media_check(
let old_is_symlink = || async {
tokio::fs::symlink_metadata(old_path)
.await
.map_or(false, |md| md.is_symlink())
.is_ok_and(|md| md.is_symlink())
};
if config.prune_missing_media && !old_exists && !new_exists {

View file

@ -413,7 +413,7 @@ async fn retroactively_fix_bad_data_from_roomuserid_joined(services: &Services)
.rooms
.state_accessor
.get_member(room_id, user_id)
.map(|member| member.map_or(false, |member| member.membership == MembershipState::Join))
.map(|member| member.is_ok_and(|member| member.membership == MembershipState::Join))
})
.collect::<Vec<_>>()
.await;
@ -426,7 +426,7 @@ async fn retroactively_fix_bad_data_from_roomuserid_joined(services: &Services)
.rooms
.state_accessor
.get_member(room_id, user_id)
.map(|member| member.map_or(false, |member| member.membership == MembershipState::Join))
.map(|member| member.is_ok_and(|member| member.membership == MembershipState::Join))
})
.collect::<Vec<_>>()
.await;

View file

@ -757,7 +757,7 @@ fn get_parent_children_via(
fn next_room_to_traverse(
stack: &mut Vec<Vec<(OwnedRoomId, Vec<OwnedServerName>)>>, parents: &mut VecDeque<OwnedRoomId>,
) -> Option<(OwnedRoomId, Vec<OwnedServerName>)> {
while stack.last().map_or(false, Vec::is_empty) {
while stack.last().is_some_and(Vec::is_empty) {
stack.pop();
parents.pop_back();
}

View file

@ -179,7 +179,6 @@ impl Data {
}
/// Returns the full room state.
#[allow(unused_qualifications)] // async traits
pub(super) async fn room_state_full(
&self, room_id: &RoomId,
) -> Result<HashMap<(StateEventType, String), Arc<PduEvent>>> {

View file

@ -616,7 +616,7 @@ impl Service {
&& pdu
.state_key
.as_ref()
.map_or(false, |state_key| users.is_match(state_key))
.is_some_and(|state_key| users.is_match(state_key))
};
let matching_aliases = |aliases: NamespaceRegex| {
self.services

View file

@ -24,10 +24,7 @@ pub(super) fn get_prefix(&self) -> Vec<u8> {
},
Self::Appservice(server) => {
let sigil = b"+";
let len = sigil
.len()
.saturating_add(server.as_bytes().len())
.saturating_add(1);
let len = sigil.len().saturating_add(server.len()).saturating_add(1);
let mut p = Vec::with_capacity(len);
p.extend_from_slice(sigil);
@ -41,7 +38,7 @@ pub(super) fn get_prefix(&self) -> Vec<u8> {
.len()
.saturating_add(user.as_bytes().len())
.saturating_add(1)
.saturating_add(pushkey.as_bytes().len())
.saturating_add(pushkey.len())
.saturating_add(1);
let mut p = Vec::with_capacity(len);

View file

@ -101,7 +101,7 @@ impl Service {
.account_data
.get_global(recipient_user, GlobalAccountDataEventType::IgnoredUserList)
.await
.map_or(false, |ignored: IgnoredUserListEvent| {
.is_ok_and(|ignored: IgnoredUserListEvent| {
ignored
.content
.ignored_users