[fractal] Redudant pattern matching removed
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal] Redudant pattern matching removed
- Date: Wed, 24 Jun 2020 07:00:37 +0000 (UTC)
commit 635eaf5295aef0a8ea57f93795f234b34dfeb325
Author: Günther Wagner <info gunibert de>
Date: Wed Jun 17 08:05:53 2020 +0200
Redudant pattern matching removed
If the value of a destructured Result/Option is not used then it is more concise
to use the is_* form for the if statement (is_err/is_none/is_ok/is_some)
fractal-gtk/src/actions/message.rs | 2 +-
fractal-gtk/src/appop/login.rs | 4 ++--
fractal-gtk/src/appop/member.rs | 2 +-
fractal-gtk/src/appop/room.rs | 2 +-
4 files changed, 5 insertions(+), 5 deletions(-)
---
diff --git a/fractal-gtk/src/actions/message.rs b/fractal-gtk/src/actions/message.rs
index 2f891829..841bf39e 100644
--- a/fractal-gtk/src/actions/message.rs
+++ b/fractal-gtk/src/actions/message.rs
@@ -169,7 +169,7 @@ pub fn new(
let window = upgrade_weak!(parent_weak, Continue(true));
if let Some(path) = save(&window, &name, &[]) {
// TODO use glib to copy file
- if let Err(_) = fs::copy(fname, path) {
+ if fs::copy(fname, path).is_err() {
ErrorDialog::new(false, &i18n("Couldn’t save file"));
}
}
diff --git a/fractal-gtk/src/appop/login.rs b/fractal-gtk/src/appop/login.rs
index aab14d11..d111ffe6 100644
--- a/fractal-gtk/src/appop/login.rs
+++ b/fractal-gtk/src/appop/login.rs
@@ -36,7 +36,7 @@ impl AppOp {
server_url: Url,
identity_url: Url,
) {
- if let Err(_) = self.store_token(uid.clone(), access_token.clone()) {
+ if self.store_token(uid.clone(), access_token.clone()).is_err() {
error!("Can't store the token using libsecret");
}
@@ -62,7 +62,7 @@ impl AppOp {
pub fn bk_logout(&mut self) {
self.set_rooms(vec![], true);
- if let Err(_) = cache::get().destroy() {
+ if cache::get().destroy().is_err() {
error!("Error removing cache file");
}
diff --git a/fractal-gtk/src/appop/member.rs b/fractal-gtk/src/appop/member.rs
index 3db71c32..2bc00c8b 100644
--- a/fractal-gtk/src/appop/member.rs
+++ b/fractal-gtk/src/appop/member.rs
@@ -160,7 +160,7 @@ impl AppOp {
let uid_term = term.and_then(|t| UserId::try_from(t.as_str()).ok());
// Adding a new user if the user
if let Some(uid) = uid_term {
- if let None = users.iter().find(|u| u.uid == uid) {
+ if users.iter().find(|u| u.uid == uid).is_none() {
let member = Member {
avatar: None,
alias: None,
diff --git a/fractal-gtk/src/appop/room.rs b/fractal-gtk/src/appop/room.rs
index f66aec7d..c1d6c720 100644
--- a/fractal-gtk/src/appop/room.rs
+++ b/fractal-gtk/src/appop/room.rs
@@ -455,7 +455,7 @@ impl AppOp {
let uid = login_data.uid;
let device_id = self.device_id.clone().unwrap_or_default();
- if let Err(_) = cache::store(&rooms, since, username, uid, device_id) {
+ if cache::store(&rooms, since, username, uid, device_id).is_err() {
error!("Error caching rooms");
};
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]