From 17f7aedb1041b5273f290bde6a813faf8d340d1c Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Sun, 19 Nov 2023 00:05:03 +0100 Subject: [PATCH] Fix some issued spotted by Clippy --- src/model/record.rs | 3 ++- src/ui/file_pane.rs | 2 +- src/ui/group_selector.rs | 5 ++--- src/ui/record_view/item.rs | 11 ++++++++--- src/ui/record_view/item_factory.rs | 8 ++++---- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/model/record.rs b/src/model/record.rs index ca23b7a..66a0e6c 100644 --- a/src/model/record.rs +++ b/src/model/record.rs @@ -220,7 +220,8 @@ pub const RECORD_TYPE_WEBSITE: RecordType = RecordType { username_field: Some("username"), password_field: Some("password"), }; -pub const RECORD_TYPES: &'static [&RecordType] = &[ + +pub const RECORD_TYPES: &[&RecordType] = &[ &RECORD_TYPE_GROUP, &RECORD_TYPE_GENERIC, &RECORD_TYPE_CREDITCARD, diff --git a/src/ui/file_pane.rs b/src/ui/file_pane.rs index b581caf..8503b5b 100644 --- a/src/ui/file_pane.rs +++ b/src/ui/file_pane.rs @@ -81,7 +81,7 @@ mod imp { let action_bar = gtk::ActionBar::builder().hexpand(true).build(); action_bar.pack_start(&action_popover_button( &RecordTypePopoverBuilder::default() - .record_types(&RECORD_TYPES) + .record_types(RECORD_TYPES) .action_name_func(|record_type| format!("file.add::{}", record_type.name)) .build(), "ps-add", diff --git a/src/ui/group_selector.rs b/src/ui/group_selector.rs index eb95887..446d40a 100644 --- a/src/ui/group_selector.rs +++ b/src/ui/group_selector.rs @@ -193,9 +193,8 @@ pub async fn select_group( }), ); - let result = match dlg.run().await { + match dlg.run().await { Some(gtk::ResponseType::Ok) => get_selected_record(&selection_model), _ => None, - }; - result + } } diff --git a/src/ui/record_view/item.rs b/src/ui/record_view/item.rs index bc9ad2b..8ce4898 100644 --- a/src/ui/record_view/item.rs +++ b/src/ui/record_view/item.rs @@ -165,12 +165,17 @@ mod imp { context_menu.popup(); } + fn record_url(&self) -> Option { + let record = self.record.borrow(); + let url = record.as_ref()?.record().url()?; + Some(url.to_string()) + } + async fn on_open_clicked(&self) { self.obj().grab_focus(); - let record_ref = self.record.borrow(); - if let Some(url) = record_ref.as_ref().and_then(|n| n.record().url()) { - show_uri(self.root_window().as_ref(), url).await; + if let Some(url) = self.record_url() { + show_uri(self.root_window().as_ref(), &url).await; } } diff --git a/src/ui/record_view/item_factory.rs b/src/ui/record_view/item_factory.rs index 9809157..a4bc19a 100644 --- a/src/ui/record_view/item_factory.rs +++ b/src/ui/record_view/item_factory.rs @@ -25,20 +25,20 @@ impl PSListItemFactory for RecordListItemFactory { let Some(record_node) = get_record_node(list_item) else { return; }; - self.mapping.remove_value(&record_item); - self.mapping.add(list_item.position(), &record_item); + self.mapping.remove_value(record_item); + self.mapping.add(list_item.position(), record_item); record_item.set_record_node(Some(record_node)); } fn unbind(&self, list_item: >k::ListItem, record_item: &PSRecordViewItem) { self.mapping.remove_key(list_item.position()); - self.mapping.remove_value(&record_item); + self.mapping.remove_value(record_item); record_item.set_record_node(None); } fn teardown(&self, _list_item: >k::ListItem, record_item: &PSRecordViewItem) { record_item.set_record_node(None); - self.mapping.remove_value(&record_item); + self.mapping.remove_value(record_item); } }