From eb21699e278b58486002a1268a08744be99a188a Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Sat, 25 Sep 2021 06:16:19 +0200 Subject: [PATCH] clippy fixes --- egui_for_winit/src/clipboard.rs | 4 +--- egui_for_winit/src/lib.rs | 20 ++++++++++---------- egui_for_winit/src/screen_reader.rs | 1 + 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/egui_for_winit/src/clipboard.rs b/egui_for_winit/src/clipboard.rs index 6771684a229..4a70d47fc94 100644 --- a/egui_for_winit/src/clipboard.rs +++ b/egui_for_winit/src/clipboard.rs @@ -27,9 +27,7 @@ impl Clipboard { if let Some(clipboard) = &mut self.copypasta { use copypasta::ClipboardProvider as _; match clipboard.get_contents() { - Ok(contents) => { - return Some(contents); - } + Ok(contents) => Some(contents), Err(err) => { eprintln!("Paste error: {}", err); None diff --git a/egui_for_winit/src/lib.rs b/egui_for_winit/src/lib.rs index 99a2318601f..66c3598c04c 100644 --- a/egui_for_winit/src/lib.rs +++ b/egui_for_winit/src/lib.rs @@ -420,7 +420,7 @@ impl State { self.set_cursor_icon(window, output.cursor_icon); if let Some(open) = output.open_url { - self.open_url(open.url); + open_url(&open.url); } if !output.copied_text.is_empty() { @@ -473,17 +473,17 @@ impl State { window.set_cursor_visible(false); } } +} - fn open_url(&mut self, _url: String) { - #[cfg(feature = "webbrowser")] - if let Err(err) = webbrowser::open(&_url) { - eprintln!("Failed to open url: {}", err); - } +fn open_url(_url: &str) { + #[cfg(feature = "webbrowser")] + if let Err(err) = webbrowser::open(_url) { + eprintln!("Failed to open url: {}", err); + } - #[cfg(not(feature = "webbrowser"))] - { - eprintln!("Cannot open url - feature \"links\" not enabled."); - } + #[cfg(not(feature = "webbrowser"))] + { + eprintln!("Cannot open url - feature \"links\" not enabled."); } } diff --git a/egui_for_winit/src/screen_reader.rs b/egui_for_winit/src/screen_reader.rs index a27c964b6f9..9397d2ea8b1 100644 --- a/egui_for_winit/src/screen_reader.rs +++ b/egui_for_winit/src/screen_reader.rs @@ -29,6 +29,7 @@ impl Default for ScreenReader { impl ScreenReader { #[cfg(not(feature = "screen_reader"))] + #[allow(clippy::unused_self)] pub fn speak(&mut self, _text: &str) {} #[cfg(feature = "screen_reader")]