diff --git a/crates/eframe/src/native/file_storage.rs b/crates/eframe/src/native/file_storage.rs index e1fdc9b8..5a3b1af3 100644 --- a/crates/eframe/src/native/file_storage.rs +++ b/crates/eframe/src/native/file_storage.rs @@ -45,7 +45,7 @@ pub fn storage_dir(app_id: &str) -> Option { #[expect(unsafe_code)] fn roaming_appdata() -> Option { use std::ffi::OsString; - use std::os::windows::ffi::OsStringExt; + use std::os::windows::ffi::OsStringExt as _; use std::ptr; use std::slice; diff --git a/crates/egui-winit/src/lib.rs b/crates/egui-winit/src/lib.rs index 03ec3e83..c196acaa 100644 --- a/crates/egui-winit/src/lib.rs +++ b/crates/egui-winit/src/lib.rs @@ -1848,8 +1848,8 @@ pub fn short_device_event_description(event: &winit::event::DeviceEvent) -> &'st use winit::event::DeviceEvent; match event { - DeviceEvent::Added { .. } => "DeviceEvent::Added", - DeviceEvent::Removed { .. } => "DeviceEvent::Removed", + DeviceEvent::Added => "DeviceEvent::Added", + DeviceEvent::Removed => "DeviceEvent::Removed", DeviceEvent::MouseMotion { .. } => "DeviceEvent::MouseMotion", DeviceEvent::MouseWheel { .. } => "DeviceEvent::MouseWheel", DeviceEvent::Motion { .. } => "DeviceEvent::Motion", @@ -1867,11 +1867,11 @@ pub fn short_window_event_description(event: &winit::event::WindowEvent) -> &'st WindowEvent::ActivationTokenDone { .. } => "WindowEvent::ActivationTokenDone", WindowEvent::Resized { .. } => "WindowEvent::Resized", WindowEvent::Moved { .. } => "WindowEvent::Moved", - WindowEvent::CloseRequested { .. } => "WindowEvent::CloseRequested", - WindowEvent::Destroyed { .. } => "WindowEvent::Destroyed", + WindowEvent::CloseRequested => "WindowEvent::CloseRequested", + WindowEvent::Destroyed => "WindowEvent::Destroyed", WindowEvent::DroppedFile { .. } => "WindowEvent::DroppedFile", WindowEvent::HoveredFile { .. } => "WindowEvent::HoveredFile", - WindowEvent::HoveredFileCancelled { .. } => "WindowEvent::HoveredFileCancelled", + WindowEvent::HoveredFileCancelled => "WindowEvent::HoveredFileCancelled", WindowEvent::Focused { .. } => "WindowEvent::Focused", WindowEvent::KeyboardInput { .. } => "WindowEvent::KeyboardInput", WindowEvent::ModifiersChanged { .. } => "WindowEvent::ModifiersChanged", @@ -1882,7 +1882,7 @@ pub fn short_window_event_description(event: &winit::event::WindowEvent) -> &'st WindowEvent::MouseWheel { .. } => "WindowEvent::MouseWheel", WindowEvent::MouseInput { .. } => "WindowEvent::MouseInput", WindowEvent::PinchGesture { .. } => "WindowEvent::PinchGesture", - WindowEvent::RedrawRequested { .. } => "WindowEvent::RedrawRequested", + WindowEvent::RedrawRequested => "WindowEvent::RedrawRequested", WindowEvent::DoubleTapGesture { .. } => "WindowEvent::DoubleTapGesture", WindowEvent::RotationGesture { .. } => "WindowEvent::RotationGesture", WindowEvent::TouchpadPressure { .. } => "WindowEvent::TouchpadPressure", diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index 751604d4..3204927b 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -3511,9 +3511,10 @@ impl Context { // Try most recently added loaders first (hence `.rev()`) for loader in bytes_loaders.iter().rev() { - match loader.load(self, uri) { - Err(load::LoadError::NotSupported) => continue, - result => return result, + let result = loader.load(self, uri); + match result { + Err(load::LoadError::NotSupported) => {} + _ => return result, } } @@ -3554,10 +3555,9 @@ impl Context { // Try most recently added loaders first (hence `.rev()`) for loader in image_loaders.iter().rev() { match loader.load(self, uri, size_hint) { - Err(load::LoadError::NotSupported) => continue, + Err(load::LoadError::NotSupported) => {} Err(load::LoadError::FormatNotSupported { detected_format }) => { format = format.or(detected_format); - continue; } result => return result, } @@ -3600,7 +3600,7 @@ impl Context { // Try most recently added loaders first (hence `.rev()`) for loader in texture_loaders.iter().rev() { match loader.load(self, uri, texture_options, size_hint) { - Err(load::LoadError::NotSupported) => continue, + Err(load::LoadError::NotSupported) => {} result => return result, } } diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index 2e35e34e..1e258067 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -256,9 +256,7 @@ impl ViewportInfo { /// If this is not the root viewport, /// it is up to the user to hide this viewport the next frame. pub fn close_requested(&self) -> bool { - self.events - .iter() - .any(|&event| event == ViewportEvent::Close) + self.events.contains(&ViewportEvent::Close) } /// Helper: move [`Self::events`], clone the other fields. diff --git a/crates/egui/src/data/output.rs b/crates/egui/src/data/output.rs index ab9044cb..233f75a4 100644 --- a/crates/egui/src/data/output.rs +++ b/crates/egui/src/data/output.rs @@ -739,7 +739,7 @@ impl WidgetInfo { if text_value.is_empty() { "blank".into() } else { - text_value.to_string() + text_value.clone() } } else { "blank".into() diff --git a/crates/egui/src/memory/mod.rs b/crates/egui/src/memory/mod.rs index e9f7d9f8..9bf482b8 100644 --- a/crates/egui/src/memory/mod.rs +++ b/crates/egui/src/memory/mod.rs @@ -1235,7 +1235,7 @@ impl Areas { self.visible_areas_current_frame.insert(layer_id); self.wants_to_be_on_top.insert(layer_id); - if !self.order.iter().any(|x| *x == layer_id) { + if !self.order.contains(&layer_id) { self.order.push(layer_id); } } @@ -1256,10 +1256,10 @@ impl Areas { self.sublayers.entry(parent).or_default().insert(child); // Make sure the layers are in the order list: - if !self.order.iter().any(|x| *x == parent) { + if !self.order.contains(&parent) { self.order.push(parent); } - if !self.order.iter().any(|x| *x == child) { + if !self.order.contains(&child) { self.order.push(child); } } @@ -1268,7 +1268,7 @@ impl Areas { self.order .iter() .filter(|layer| layer.order == order && !self.is_sublayer(layer)) - .last() + .next_back() .copied() } diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index ca201edd..29f4b2cb 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -863,9 +863,11 @@ impl TextEdit<'_> { fn mask_if_password(is_password: bool, text: &str) -> String { fn mask_password(text: &str) -> String { - std::iter::repeat(epaint::text::PASSWORD_REPLACEMENT_CHAR) - .take(text.chars().count()) - .collect::() + std::iter::repeat_n( + epaint::text::PASSWORD_REPLACEMENT_CHAR, + text.chars().count(), + ) + .collect::() } if is_password { diff --git a/crates/egui_demo_lib/src/demo/screenshot.rs b/crates/egui_demo_lib/src/demo/screenshot.rs index c2367914..64370ec0 100644 --- a/crates/egui_demo_lib/src/demo/screenshot.rs +++ b/crates/egui_demo_lib/src/demo/screenshot.rs @@ -58,7 +58,7 @@ impl crate::View for Screenshot { None } }) - .last() + .next_back() }); if let Some(image) = image { diff --git a/crates/egui_demo_lib/src/demo/tests/grid_test.rs b/crates/egui_demo_lib/src/demo/tests/grid_test.rs index 511aa428..0b7bfa48 100644 --- a/crates/egui_demo_lib/src/demo/tests/grid_test.rs +++ b/crates/egui_demo_lib/src/demo/tests/grid_test.rs @@ -110,7 +110,7 @@ impl crate::View for GridTest { ui.end_row(); let mut dyn_text = String::from("O"); - dyn_text.extend(std::iter::repeat('h').take(self.text_length)); + dyn_text.extend(std::iter::repeat_n('h', self.text_length)); ui.label(dyn_text); ui.label("Fifth row, second column"); ui.end_row();