misc: Use is_some_and instead of map_or

This commit is contained in:
Kévin Commaille 2023-12-20 17:13:37 +01:00
parent 9d2d8c389c
commit af547243a7
No known key found for this signature in database
GPG Key ID: 29A48C1F03620416
6 changed files with 7 additions and 7 deletions

View File

@ -199,7 +199,7 @@ impl LabelWithWidgets {
fn allocate_shapes(&self) {
let imp = self.imp();
if imp.label.borrow().as_ref().map_or(true, |s| s.is_empty()) {
if !imp.label.borrow().as_ref().is_some_and(|s| !s.is_empty()) {
// No need to compute shapes if the label is empty.
return;
}

View File

@ -273,6 +273,6 @@ impl MemberList {
.members
.borrow()
.get(user_id)
.map_or_else(|| Membership::Leave, |member| member.membership())
.map_or(Membership::Leave, |member| member.membership())
}
}

View File

@ -84,7 +84,7 @@ mod imp {
.map(|target_room_type| (source_room_type, target_room_type))
});
room_types.map_or(false, |(source_room_type, target_room_type)| {
room_types.is_some_and(|(source_room_type, target_room_type)| {
source_room_type.can_change_to(target_room_type)
})
};

View File

@ -178,7 +178,7 @@ impl User {
/// Load whether this user is verified.
fn init_is_verified(&self) {
spawn!(clone!(@weak self as obj => async move {
let verified = obj.crypto_identity().await.map_or(false, |i| i.is_verified());
let verified = obj.crypto_identity().await.is_some_and(|i| i.is_verified());
if verified == obj.verified() {
return;

View File

@ -143,7 +143,7 @@ mod imp {
.focus_child()
.and_then(|w| w.focus_child())
.and_then(|w| w.focus_child());
if focus_child.map_or(false, |w| w.is::<gtk::ListView>())
if focus_child.is_some_and(|w| w.is::<gtk::ListView>())
&& matches!(
direction_type,
gtk::DirectionType::TabForward | gtk::DirectionType::TabBackward

View File

@ -322,14 +322,14 @@ impl Row {
if let Some(source_type) = source_type {
if self
.room_type()
.map_or(false, |row_type| source_type.can_change_to(row_type))
.is_some_and(|row_type| source_type.can_change_to(row_type))
{
self.remove_css_class("drop-disabled");
if self
.item()
.and_downcast::<Category>()
.map_or(false, |category| category.empty())
.is_some_and(|category| category.empty())
{
self.add_css_class("drop-empty");
} else {