[fractal/remove-clippy-warnings: 2/7] clippy: Remove redundant clones
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [fractal/remove-clippy-warnings: 2/7] clippy: Remove redundant clones
- Date: Mon, 6 Jul 2020 06:04:37 +0000 (UTC)
commit c06d54b923d156ef5c92448dbae49c9e101e7cc3
Author: Daniel García Moreno <dani danigm net>
Date: Thu Jul 2 09:50:38 2020 +0200
clippy: Remove redundant clones
https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone
fractal-gtk/src/app/backend_loop.rs | 2 +-
fractal-gtk/src/app/connect/markdown.rs | 56 ++++++++++++++++-----------------
fractal-gtk/src/app/connect/new_room.rs | 2 +-
fractal-gtk/src/appop/message.rs | 4 +--
fractal-gtk/src/appop/user.rs | 4 +--
fractal-gtk/src/widgets/media_viewer.rs | 1 -
fractal-gtk/src/widgets/room.rs | 8 ++---
fractal-gtk/src/widgets/roomrow.rs | 2 +-
8 files changed, 38 insertions(+), 41 deletions(-)
---
diff --git a/fractal-gtk/src/app/backend_loop.rs b/fractal-gtk/src/app/backend_loop.rs
index bacb1efe..c608f860 100644
--- a/fractal-gtk/src/app/backend_loop.rs
+++ b/fractal-gtk/src/app/backend_loop.rs
@@ -92,7 +92,7 @@ pub fn dispatch_error(error: BKError) {
"{}",
remove_matrix_access_token_if_present(&err_str).unwrap_or(err_str)
);
- let error = i18n("Can’t join the room, try again.").to_string();
+ let error = i18n("Can’t join the room, try again.");
let state = AppState::NoRoom;
APPOP!(show_error, (error));
APPOP!(set_state, (state));
diff --git a/fractal-gtk/src/app/connect/markdown.rs b/fractal-gtk/src/app/connect/markdown.rs
index 15d09ad8..13cbdafa 100644
--- a/fractal-gtk/src/app/connect/markdown.rs
+++ b/fractal-gtk/src/app/connect/markdown.rs
@@ -49,37 +49,35 @@ impl App {
}
}
- markdown_switch
- .clone()
- .connect_property_active_notify(move |_| {
- op.lock().unwrap().md_enabled = markdown_switch.get_active();
+ markdown_switch.connect_property_active_notify(clone!(markdown_switch => move |_| {
+ op.lock().unwrap().md_enabled = markdown_switch.get_active();
- if markdown_switch.get_active() {
- md_img.set_from_icon_name(
- Some("format-indent-more-symbolic"),
- gtk::IconSize::Menu,
- );
- txt.get_style_context().remove_class("dim-label");
- util::set_markdown_schema(true);
+ if markdown_switch.get_active() {
+ md_img.set_from_icon_name(
+ Some("format-indent-more-symbolic"),
+ gtk::IconSize::Menu,
+ );
+ txt.get_style_context().remove_class("dim-label");
+ util::set_markdown_schema(true);
- if let Some(md_lang) = md_lang.clone() {
- buffer.set_highlight_matching_brackets(true);
- buffer.set_language(Some(&md_lang));
- buffer.set_highlight_syntax(true);
- }
- } else {
- md_img.set_from_icon_name(
- Some("format-justify-left-symbolic"),
- gtk::IconSize::Menu,
- );
- txt.get_style_context().add_class("dim-label");
- util::set_markdown_schema(false);
-
- let lang: Option<&sourceview4::Language> = None;
- buffer.set_highlight_matching_brackets(false);
- buffer.set_language(lang);
- buffer.set_highlight_syntax(false);
+ if let Some(md_lang) = md_lang.clone() {
+ buffer.set_highlight_matching_brackets(true);
+ buffer.set_language(Some(&md_lang));
+ buffer.set_highlight_syntax(true);
}
- });
+ } else {
+ md_img.set_from_icon_name(
+ Some("format-justify-left-symbolic"),
+ gtk::IconSize::Menu,
+ );
+ txt.get_style_context().add_class("dim-label");
+ util::set_markdown_schema(false);
+
+ let lang: Option<&sourceview4::Language> = None;
+ buffer.set_highlight_matching_brackets(false);
+ buffer.set_language(lang);
+ buffer.set_highlight_syntax(false);
+ }
+ }));
}
}
diff --git a/fractal-gtk/src/app/connect/new_room.rs b/fractal-gtk/src/app/connect/new_room.rs
index 96cbd8ea..eb675a8b 100644
--- a/fractal-gtk/src/app/connect/new_room.rs
+++ b/fractal-gtk/src/app/connect/new_room.rs
@@ -31,7 +31,7 @@ impl App {
.get_object::<gtk::ToggleButton>("private_visibility_button")
.expect("Can't find private_visibility_button in ui file.");
- private.clone().set_active(true);
+ private.set_active(true);
cancel.connect_clicked(clone!(entry, dialog, private => move |_| {
dialog.hide();
entry.set_text("");
diff --git a/fractal-gtk/src/appop/message.rs b/fractal-gtk/src/appop/message.rs
index 182cf64b..93e60b9b 100644
--- a/fractal-gtk/src/appop/message.rs
+++ b/fractal-gtk/src/appop/message.rs
@@ -486,7 +486,7 @@ impl AppOp {
/* set message type to mention if the body contains the username, we should
* also match for MXID */
let is_mention = if let Some(user) = login_data.username.clone() {
- msg.sender != login_data.uid.clone() && msg.body.contains(&user)
+ msg.sender != login_data.uid && msg.body.contains(&user)
} else {
false
};
@@ -519,7 +519,7 @@ impl AppOp {
.get(&login_data.uid)
.copied()
.unwrap_or_default();
- let redactable = admin != 0 || login_data.uid.clone() == msg.sender;
+ let redactable = admin != 0 || login_data.uid == msg.sender;
let is_last_viewed = msg.receipt.contains_key(&login_data.uid);
Some(create_ui_message(
diff --git a/fractal-gtk/src/appop/user.rs b/fractal-gtk/src/appop/user.rs
index e8281a82..14c9bd81 100644
--- a/fractal-gtk/src/appop/user.rs
+++ b/fractal-gtk/src/appop/user.rs
@@ -104,7 +104,7 @@ impl AppOp {
}
let eb = gtk::EventBox::new();
- match login_data.avatar.clone() {
+ match login_data.avatar {
Some(_) => {
let w = widgets::Avatar::avatar_new(Some(24));
let data = w.circle(
@@ -118,7 +118,7 @@ impl AppOp {
self.thread_pool.clone(),
self.user_info_cache.clone(),
login_data.server_url.clone(),
- login_data.uid.clone(),
+ login_data.uid,
data,
);
diff --git a/fractal-gtk/src/widgets/media_viewer.rs b/fractal-gtk/src/widgets/media_viewer.rs
index 3c534476..40178c63 100644
--- a/fractal-gtk/src/widgets/media_viewer.rs
+++ b/fractal-gtk/src/widgets/media_viewer.rs
@@ -155,7 +155,6 @@ impl Data {
admins: HashMap<UserId, i32>,
) -> Data {
let is_fullscreen = main_window
- .clone()
.get_window()
.unwrap()
.get_state()
diff --git a/fractal-gtk/src/widgets/room.rs b/fractal-gtk/src/widgets/room.rs
index fcac53b0..b64797c4 100644
--- a/fractal-gtk/src/widgets/room.rs
+++ b/fractal-gtk/src/widgets/room.rs
@@ -129,16 +129,16 @@ impl<'a> RoomBox<'a> {
let server_url = login_data.server_url.clone();
let access_token = login_data.access_token.clone();
let room_id = room_id.clone();
- thread::spawn(move || {
- match room::join_room(server_url, access_token, room_id.clone()) {
+ thread::spawn(
+ move || match room::join_room(server_url, access_token, room_id) {
Ok(jtr) => {
let jtr = Some(jtr);
APPOP!(set_join_to_room, (jtr));
APPOP!(reload_rooms);
}
Err(err) => dispatch_error(BKError::JoinRoomError(err)),
- }
- });
+ },
+ );
});
join_button.set_property_width_request(JOIN_BUTTON_WIDTH);
diff --git a/fractal-gtk/src/widgets/roomrow.rs b/fractal-gtk/src/widgets/roomrow.rs
index 8a7ad3b2..444de44d 100644
--- a/fractal-gtk/src/widgets/roomrow.rs
+++ b/fractal-gtk/src/widgets/roomrow.rs
@@ -31,7 +31,7 @@ impl RoomRow {
gtk::Image::new_from_icon_name(Some("avatar-default-symbolic"), gtk::IconSize::Menu);
direct.get_style_context().add_class("direct-chat");
- let text = gtk::Label::new(Some(name.clone().as_str()));
+ let text = gtk::Label::new(Some(name.as_str()));
text.set_valign(gtk::Align::Start);
text.set_halign(gtk::Align::Start);
text.set_ellipsize(pango::EllipsizeMode::End);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]