From aa78304e6fbf7d13676516349d037e532da2f79d Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 30 Jun 2025 13:46:12 +0200 Subject: [PATCH 1/4] Update to edition 2024 and run cargo fmt --- Cargo.toml | 2 +- crates/ecolor/src/cint_impl.rs | 2 +- crates/ecolor/src/color32.rs | 2 +- crates/ecolor/src/hsva.rs | 2 +- crates/ecolor/src/hsva_gamma.rs | 2 +- crates/eframe/README.md | 2 +- crates/eframe/src/epi.rs | 8 ++++-- crates/eframe/src/native/app_icon.rs | 4 ++- crates/eframe/src/native/file_storage.rs | 2 +- crates/eframe/src/native/glow_integration.rs | 10 ++++--- crates/eframe/src/native/run.rs | 3 +-- crates/eframe/src/native/wgpu_integration.rs | 2 +- crates/eframe/src/web/app_runner.rs | 4 +-- crates/eframe/src/web/events.rs | 9 +++---- crates/eframe/src/web/input.rs | 2 +- crates/eframe/src/web/web_logger.rs | 13 +++++++--- crates/eframe/src/web/web_painter_wgpu.rs | 2 +- crates/eframe/src/web/web_runner.rs | 4 +-- crates/egui-wgpu/src/capture.rs | 7 +++-- crates/egui-wgpu/src/renderer.rs | 14 +++++++--- crates/egui-wgpu/src/winit.rs | 12 ++++++--- crates/egui-winit/src/clipboard.rs | 4 ++- crates/egui/src/animation_manager.rs | 2 +- crates/egui/src/callstack.rs | 13 +++++++--- crates/egui/src/containers/area.rs | 4 +-- .../egui/src/containers/collapsing_header.rs | 6 ++--- crates/egui/src/containers/combo_box.rs | 6 ++--- crates/egui/src/containers/frame.rs | 7 ++--- crates/egui/src/containers/menu.rs | 2 +- crates/egui/src/containers/panel.rs | 4 +-- crates/egui/src/containers/popup.rs | 4 +-- crates/egui/src/containers/resize.rs | 4 +-- crates/egui/src/containers/scene.rs | 4 +-- crates/egui/src/containers/scroll_area.rs | 4 +-- crates/egui/src/containers/window.rs | 2 +- crates/egui/src/context.rs | 26 ++++++++++++------- crates/egui/src/data/input.rs | 2 +- crates/egui/src/debug_text.rs | 2 +- crates/egui/src/grid.rs | 4 +-- crates/egui/src/hit_test.rs | 4 +-- crates/egui/src/input_state/mod.rs | 6 ++--- crates/egui/src/input_state/touch_state.rs | 4 +-- crates/egui/src/interaction.rs | 2 +- crates/egui/src/introspection.rs | 4 +-- crates/egui/src/layers.rs | 4 +-- crates/egui/src/layout.rs | 2 +- crates/egui/src/lib.rs | 15 +++++------ crates/egui/src/load.rs | 2 +- crates/egui/src/load/bytes_loader.rs | 4 +-- crates/egui/src/memory/mod.rs | 13 ++++++---- crates/egui/src/memory/theme.rs | 6 +---- crates/egui/src/menu.rs | 9 +++---- crates/egui/src/os.rs | 3 ++- crates/egui/src/painter.rs | 4 +-- crates/egui/src/pass_state.rs | 4 +-- crates/egui/src/placer.rs | 2 +- crates/egui/src/response.rs | 5 ++-- crates/egui/src/style.rs | 8 +++--- .../egui/src/text_selection/accesskit_text.rs | 2 +- .../egui/src/text_selection/cursor_range.rs | 4 +-- .../text_selection/label_text_selection.rs | 8 +++--- .../src/text_selection/text_cursor_state.rs | 4 +-- crates/egui/src/text_selection/visuals.rs | 2 +- crates/egui/src/ui.rs | 16 ++++++------ crates/egui/src/ui_builder.rs | 2 +- crates/egui/src/widget_text.rs | 2 +- crates/egui/src/widgets/checkbox.rs | 4 +-- crates/egui/src/widgets/color_picker.rs | 7 ++--- crates/egui/src/widgets/drag_value.rs | 4 +-- crates/egui/src/widgets/hyperlink.rs | 4 +-- crates/egui/src/widgets/image.rs | 9 ++++--- crates/egui/src/widgets/image_button.rs | 4 +-- crates/egui/src/widgets/label.rs | 4 +-- crates/egui/src/widgets/mod.rs | 4 +-- crates/egui/src/widgets/progress_bar.rs | 4 +-- crates/egui/src/widgets/radio_button.rs | 4 +-- crates/egui/src/widgets/separator.rs | 2 +- crates/egui/src/widgets/slider.rs | 12 +++------ crates/egui/src/widgets/spinner.rs | 2 +- crates/egui/src/widgets/text_edit/builder.rs | 12 ++++----- crates/egui/src/widgets/text_edit/state.rs | 2 +- .../egui/src/widgets/text_edit/text_buffer.rs | 2 +- .../egui_demo_app/src/apps/fractal_clock.rs | 2 +- crates/egui_demo_app/src/apps/image_viewer.rs | 6 ++--- crates/egui_demo_app/src/frame_history.rs | 2 +- crates/egui_demo_app/src/main.rs | 4 ++- crates/egui_demo_app/tests/test_demo_app.rs | 4 +-- crates/egui_demo_lib/benches/benchmark.rs | 4 +-- .../egui_demo_lib/src/demo/dancing_strings.rs | 3 ++- .../src/demo/demo_app_windows.rs | 4 +-- .../egui_demo_lib/src/demo/drag_and_drop.rs | 2 +- .../src/demo/misc_demo_window.rs | 4 +-- crates/egui_demo_lib/src/demo/modals.rs | 4 +-- crates/egui_demo_lib/src/demo/multi_touch.rs | 3 ++- crates/egui_demo_lib/src/demo/paint_bezier.rs | 6 ++--- crates/egui_demo_lib/src/demo/painting.rs | 2 +- crates/egui_demo_lib/src/demo/popups.rs | 6 ++--- crates/egui_demo_lib/src/demo/scrolling.rs | 4 +-- crates/egui_demo_lib/src/demo/sliders.rs | 2 +- crates/egui_demo_lib/src/demo/table_demo.rs | 4 ++- .../src/demo/tests/layout_test.rs | 2 +- .../src/demo/tests/tessellation_test.rs | 3 ++- crates/egui_demo_lib/src/demo/text_edit.rs | 4 +-- crates/egui_demo_lib/src/demo/undo_redo.rs | 2 +- .../src/easy_mark/easy_mark_editor.rs | 2 +- .../src/easy_mark/easy_mark_viewer.rs | 4 +-- crates/egui_demo_lib/src/rendering_test.rs | 8 +++--- crates/egui_extras/src/layout.rs | 2 +- .../egui_extras/src/loaders/ehttp_loader.rs | 4 +-- crates/egui_extras/src/loaders/gif_loader.rs | 3 +-- .../egui_extras/src/loaders/image_loader.rs | 3 +-- crates/egui_extras/src/loaders/svg_loader.rs | 4 +-- crates/egui_extras/src/loaders/webp_loader.rs | 7 +++-- crates/egui_extras/src/strip.rs | 2 +- crates/egui_extras/src/syntax_highlighting.rs | 2 +- crates/egui_extras/src/table.rs | 4 +-- crates/egui_glow/src/lib.rs | 8 ++---- crates/egui_glow/src/painter.rs | 4 ++- crates/egui_glow/src/shader_version.rs | 6 +---- crates/egui_glow/src/winit.rs | 2 +- crates/egui_kittest/src/node.rs | 4 +-- crates/egui_kittest/src/snapshot.rs | 16 +++++++----- crates/egui_kittest/src/wgpu.rs | 2 +- crates/egui_kittest/tests/accesskit.rs | 2 +- crates/egui_kittest/tests/menu.rs | 2 +- crates/egui_kittest/tests/regression_tests.rs | 2 +- crates/egui_kittest/tests/tests.rs | 2 +- crates/emath/src/align.rs | 2 +- crates/emath/src/easing.rs | 6 +---- crates/emath/src/lib.rs | 8 ++---- crates/emath/src/pos2.rs | 2 +- crates/emath/src/rect.rs | 2 +- crates/emath/src/rect_transform.rs | 2 +- crates/emath/src/vec2.rs | 6 +---- crates/epaint/benches/benchmark.rs | 6 ++--- crates/epaint/src/image.rs | 2 +- crates/epaint/src/lib.rs | 2 +- crates/epaint/src/margin.rs | 2 +- crates/epaint/src/margin_f32.rs | 2 +- crates/epaint/src/mesh.rs | 2 +- crates/epaint/src/shadow.rs | 3 ++- crates/epaint/src/shape_transform.rs | 4 +-- crates/epaint/src/shapes/rect_shape.rs | 3 ++- crates/epaint/src/shapes/shape.rs | 7 ++--- crates/epaint/src/stroke.rs | 2 +- crates/epaint/src/tessellator.rs | 18 ++++++------- crates/epaint/src/text/font.rs | 4 +-- crates/epaint/src/text/fonts.rs | 6 ++--- crates/epaint/src/text/text_layout.rs | 4 +-- crates/epaint/src/text/text_layout_types.rs | 2 +- crates/epaint/src/texture_atlas.rs | 2 +- crates/epaint/src/texture_handle.rs | 4 +-- examples/confirm_exit/Cargo.toml | 2 +- examples/custom_3d_glow/Cargo.toml | 2 +- examples/custom_font/Cargo.toml | 2 +- examples/custom_font_style/Cargo.toml | 2 +- examples/custom_keypad/Cargo.toml | 2 +- examples/custom_keypad/src/keypad.rs | 2 +- examples/custom_style/Cargo.toml | 2 +- examples/custom_style/src/main.rs | 2 +- examples/custom_window_frame/Cargo.toml | 2 +- examples/custom_window_frame/src/main.rs | 2 +- examples/external_eventloop/Cargo.toml | 2 +- examples/external_eventloop/src/main.rs | 2 +- examples/external_eventloop_async/Cargo.toml | 2 +- examples/external_eventloop_async/src/app.rs | 2 +- examples/file_dialog/Cargo.toml | 2 +- examples/hello_android/Cargo.toml | 2 +- examples/hello_android/src/lib.rs | 2 +- examples/hello_world/Cargo.toml | 2 +- examples/hello_world_par/Cargo.toml | 2 +- examples/hello_world_simple/Cargo.toml | 2 +- examples/images/Cargo.toml | 2 +- examples/keyboard_events/Cargo.toml | 2 +- examples/multiple_viewports/Cargo.toml | 2 +- examples/multiple_viewports/src/main.rs | 2 +- examples/puffin_profiler/Cargo.toml | 2 +- examples/puffin_profiler/src/main.rs | 2 +- examples/screenshot/Cargo.toml | 2 +- examples/serial_windows/Cargo.toml | 2 +- examples/user_attention/Cargo.toml | 2 +- examples/user_attention/src/main.rs | 2 +- tests/egui_tests/tests/regression_tests.rs | 4 +-- tests/egui_tests/tests/test_widgets.rs | 8 +++--- tests/test_egui_extras_compilation/Cargo.toml | 2 +- tests/test_inline_glow_paint/Cargo.toml | 2 +- tests/test_size_pass/Cargo.toml | 2 +- tests/test_ui_stack/Cargo.toml | 2 +- tests/test_viewports/Cargo.toml | 2 +- tests/test_viewports/src/main.rs | 2 +- 190 files changed, 408 insertions(+), 380 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a5a480da7a8..5b8b00278ab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,7 +21,7 @@ members = [ ] [workspace.package] -edition = "2021" +edition = "2024" license = "MIT OR Apache-2.0" rust-version = "1.85" version = "0.31.1" diff --git a/crates/ecolor/src/cint_impl.rs b/crates/ecolor/src/cint_impl.rs index 5d34e5e36f7..3d9c9d2a6eb 100644 --- a/crates/ecolor/src/cint_impl.rs +++ b/crates/ecolor/src/cint_impl.rs @@ -1,4 +1,4 @@ -use super::{linear_f32_from_linear_u8, linear_u8_from_linear_f32, Color32, Hsva, HsvaGamma, Rgba}; +use super::{Color32, Hsva, HsvaGamma, Rgba, linear_f32_from_linear_u8, linear_u8_from_linear_f32}; use cint::{Alpha, ColorInterop, EncodedSrgb, Hsv, LinearSrgb, PremultipliedAlpha}; // ---- Color32 ---- diff --git a/crates/ecolor/src/color32.rs b/crates/ecolor/src/color32.rs index 55e3f232e5b..eaa1ce2c350 100644 --- a/crates/ecolor/src/color32.rs +++ b/crates/ecolor/src/color32.rs @@ -1,4 +1,4 @@ -use crate::{fast_round, linear_f32_from_linear_u8, Rgba}; +use crate::{Rgba, fast_round, linear_f32_from_linear_u8}; /// This format is used for space-efficient color representation (32 bits). /// diff --git a/crates/ecolor/src/hsva.rs b/crates/ecolor/src/hsva.rs index 8388e41392d..97aed1b599c 100644 --- a/crates/ecolor/src/hsva.rs +++ b/crates/ecolor/src/hsva.rs @@ -1,5 +1,5 @@ use crate::{ - gamma_u8_from_linear_f32, linear_f32_from_gamma_u8, linear_u8_from_linear_f32, Color32, Rgba, + Color32, Rgba, gamma_u8_from_linear_f32, linear_f32_from_gamma_u8, linear_u8_from_linear_f32, }; /// Hue, saturation, value, alpha. All in the range [0, 1]. diff --git a/crates/ecolor/src/hsva_gamma.rs b/crates/ecolor/src/hsva_gamma.rs index 67e167677db..19e31f337b6 100644 --- a/crates/ecolor/src/hsva_gamma.rs +++ b/crates/ecolor/src/hsva_gamma.rs @@ -1,4 +1,4 @@ -use crate::{gamma_from_linear, linear_from_gamma, Color32, Hsva, Rgba}; +use crate::{Color32, Hsva, Rgba, gamma_from_linear, linear_from_gamma}; /// Like Hsva but with the `v` value (brightness) being gamma corrected /// so that it is somewhat perceptually even. diff --git a/crates/eframe/README.md b/crates/eframe/README.md index 3d787c572bb..9dbf42caf5d 100644 --- a/crates/eframe/README.md +++ b/crates/eframe/README.md @@ -24,7 +24,7 @@ To use on Linux, first run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev ``` -You need to either use `edition = "2021"`, or set `resolver = "2"` in the `[workspace]` section of your to-level `Cargo.toml`. See [this link](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) for more info. +You need to either use `edition = "2024"`, or set `resolver = "2"` in the `[workspace]` section of your to-level `Cargo.toml`. See [this link](https://doc.rust-lang.org/edition-guide/rust-2021/default-cargo-resolver.html) for more info. You can opt-in to the using [`egui-wgpu`](https://github.com/emilk/egui/tree/main/crates/egui-wgpu) for rendering by enabling the `wgpu` feature and setting `NativeOptions::renderer` to `Renderer::Wgpu`. diff --git a/crates/eframe/src/epi.rs b/crates/eframe/src/epi.rs index eb0087b12e6..3e6023270b0 100644 --- a/crates/eframe/src/epi.rs +++ b/crates/eframe/src/epi.rs @@ -574,7 +574,9 @@ impl Default for Renderer { fn default() -> Self { #[cfg(not(feature = "glow"))] #[cfg(not(feature = "wgpu"))] - compile_error!("eframe: you must enable at least one of the rendering backend features: 'glow' or 'wgpu'"); + compile_error!( + "eframe: you must enable at least one of the rendering backend features: 'glow' or 'wgpu'" + ); #[cfg(feature = "glow")] #[cfg(not(feature = "wgpu"))] @@ -617,7 +619,9 @@ impl std::str::FromStr for Renderer { #[cfg(feature = "wgpu")] "wgpu" => Ok(Self::Wgpu), - _ => Err(format!("eframe renderer {name:?} is not available. Make sure that the corresponding eframe feature is enabled.")) + _ => Err(format!( + "eframe renderer {name:?} is not available. Make sure that the corresponding eframe feature is enabled." + )), } } } diff --git a/crates/eframe/src/native/app_icon.rs b/crates/eframe/src/native/app_icon.rs index ed240021b26..cbe31e2b356 100644 --- a/crates/eframe/src/native/app_icon.rs +++ b/crates/eframe/src/native/app_icon.rs @@ -240,7 +240,9 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS use objc2_app_kit::{NSBitmapImageRep, NSDeviceRGBColorSpace}; use objc2_foundation::NSSize; - log::trace!("NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel"); + log::trace!( + "NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel" + ); let Some(image_rep) = NSBitmapImageRep::initWithBitmapDataPlanes_pixelsWide_pixelsHigh_bitsPerSample_samplesPerPixel_hasAlpha_isPlanar_colorSpaceName_bytesPerRow_bitsPerPixel( NSBitmapImageRep::alloc(), [image.as_raw().as_ptr().cast_mut()].as_mut_ptr(), diff --git a/crates/eframe/src/native/file_storage.rs b/crates/eframe/src/native/file_storage.rs index 5a3b1af324e..d2d16281eab 100644 --- a/crates/eframe/src/native/file_storage.rs +++ b/crates/eframe/src/native/file_storage.rs @@ -52,7 +52,7 @@ fn roaming_appdata() -> Option { use windows_sys::Win32::Foundation::S_OK; use windows_sys::Win32::System::Com::CoTaskMemFree; use windows_sys::Win32::UI::Shell::{ - FOLDERID_RoamingAppData, SHGetKnownFolderPath, KF_FLAG_DONT_VERIFY, + FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath, }; extern "C" { diff --git a/crates/eframe/src/native/glow_integration.rs b/crates/eframe/src/native/glow_integration.rs index 15ade4a385d..c83a6f14b21 100644 --- a/crates/eframe/src/native/glow_integration.rs +++ b/crates/eframe/src/native/glow_integration.rs @@ -32,13 +32,13 @@ use egui::{ use egui_winit::accesskit_winit; use crate::{ - native::epi_integration::EpiIntegration, App, AppCreator, CreationContext, NativeOptions, - Result, Storage, + App, AppCreator, CreationContext, NativeOptions, Result, Storage, + native::epi_integration::EpiIntegration, }; use super::{ epi_integration, event_loop_context, - winit_integration::{create_egui_context, EventResult, UserEvent, WinitApp}, + winit_integration::{EventResult, UserEvent, WinitApp, create_egui_context}, }; // ---------------------------------------------------------------------------- @@ -1015,7 +1015,9 @@ impl GlutinWindowContext { let gl_context = match gl_context_result { Ok(it) => it, Err(err) => { - log::warn!("Failed to create context using default context attributes {context_attributes:?} due to error: {err}"); + log::warn!( + "Failed to create context using default context attributes {context_attributes:?} due to error: {err}" + ); log::debug!( "Retrying with fallback context attributes: {fallback_context_attributes:?}" ); diff --git a/crates/eframe/src/native/run.rs b/crates/eframe/src/native/run.rs index 8edfdbe2ef4..9c31aefe69f 100644 --- a/crates/eframe/src/native/run.rs +++ b/crates/eframe/src/native/run.rs @@ -10,9 +10,8 @@ use ahash::HashMap; use super::winit_integration::{UserEvent, WinitApp}; use crate::{ - epi, + Result, epi, native::{event_loop_context, winit_integration::EventResult}, - Result, }; // ---------------------------------------------------------------------------- diff --git a/crates/eframe/src/native/wgpu_integration.rs b/crates/eframe/src/native/wgpu_integration.rs index 96e93300eab..f387779d747 100644 --- a/crates/eframe/src/native/wgpu_integration.rs +++ b/crates/eframe/src/native/wgpu_integration.rs @@ -25,8 +25,8 @@ use egui_winit::accesskit_winit; use winit_integration::UserEvent; use crate::{ - native::{epi_integration::EpiIntegration, winit_integration::EventResult}, App, AppCreator, CreationContext, NativeOptions, Result, Storage, + native::{epi_integration::EpiIntegration, winit_integration::EventResult}, }; use super::{epi_integration, event_loop_context, winit_integration, winit_integration::WinitApp}; diff --git a/crates/eframe/src/web/app_runner.rs b/crates/eframe/src/web/app_runner.rs index 675c57becee..9f2d2beba7c 100644 --- a/crates/eframe/src/web/app_runner.rs +++ b/crates/eframe/src/web/app_runner.rs @@ -1,8 +1,8 @@ use egui::{TexturesDelta, UserData, ViewportCommand}; -use crate::{epi, App}; +use crate::{App, epi}; -use super::{now_sec, text_agent::TextAgent, web_painter::WebPainter as _, NeedRepaint}; +use super::{NeedRepaint, now_sec, text_agent::TextAgent, web_painter::WebPainter as _}; pub struct AppRunner { #[allow(dead_code, clippy::allow_attributes)] diff --git a/crates/eframe/src/web/events.rs b/crates/eframe/src/web/events.rs index 521d43941aa..2bffdb78074 100644 --- a/crates/eframe/src/web/events.rs +++ b/crates/eframe/src/web/events.rs @@ -1,11 +1,10 @@ use crate::web::string_from_js_value; use super::{ - button_from_mouse_event, location_hash, modifiers_from_kb_event, modifiers_from_mouse_event, - modifiers_from_wheel_event, native_pixels_per_point, pos_from_mouse_event, - prefers_color_scheme_dark, primary_touch_pos, push_touches, text_from_keyboard_event, - theme_from_dark_mode, translate_key, AppRunner, Closure, JsCast as _, JsValue, WebRunner, - DEBUG_RESIZE, + AppRunner, Closure, DEBUG_RESIZE, JsCast as _, JsValue, WebRunner, button_from_mouse_event, + location_hash, modifiers_from_kb_event, modifiers_from_mouse_event, modifiers_from_wheel_event, + native_pixels_per_point, pos_from_mouse_event, prefers_color_scheme_dark, primary_touch_pos, + push_touches, text_from_keyboard_event, theme_from_dark_mode, translate_key, }; use web_sys::{Document, EventTarget, ShadowRoot}; diff --git a/crates/eframe/src/web/input.rs b/crates/eframe/src/web/input.rs index eecf7c1f5c5..c27897090b8 100644 --- a/crates/eframe/src/web/input.rs +++ b/crates/eframe/src/web/input.rs @@ -1,4 +1,4 @@ -use super::{canvas_content_rect, AppRunner}; +use super::{AppRunner, canvas_content_rect}; pub fn pos_from_mouse_event( canvas: &web_sys::HtmlCanvasElement, diff --git a/crates/eframe/src/web/web_logger.rs b/crates/eframe/src/web/web_logger.rs index fe0eaaebebb..01c347b7e65 100644 --- a/crates/eframe/src/web/web_logger.rs +++ b/crates/eframe/src/web/web_logger.rs @@ -126,12 +126,17 @@ fn shorten_file_path(file_path: &str) -> &str { #[test] fn test_shorten_file_path() { for (before, after) in [ - ("/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs", "tokio-1.24.1/src/runtime/runtime.rs"), + ( + "/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs", + "tokio-1.24.1/src/runtime/runtime.rs", + ), ("crates/rerun/src/main.rs", "rerun/src/main.rs"), - ("/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs", "core/src/ops/function.rs"), + ( + "/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs", + "core/src/ops/function.rs", + ), ("/weird/path/file.rs", "/weird/path/file.rs"), - ] - { + ] { assert_eq!(shorten_file_path(before), after); } } diff --git a/crates/eframe/src/web/web_painter_wgpu.rs b/crates/eframe/src/web/web_painter_wgpu.rs index 3cfc53f1ca6..debc6c5d134 100644 --- a/crates/eframe/src/web/web_painter_wgpu.rs +++ b/crates/eframe/src/web/web_painter_wgpu.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use super::web_painter::WebPainter; use crate::WebOptions; use egui::{Event, UserData, ViewportId}; -use egui_wgpu::capture::{capture_channel, CaptureReceiver, CaptureSender, CaptureState}; +use egui_wgpu::capture::{CaptureReceiver, CaptureSender, CaptureState, capture_channel}; use egui_wgpu::{RenderState, SurfaceErrorAction}; use wasm_bindgen::JsValue; use web_sys::HtmlCanvasElement; diff --git a/crates/eframe/src/web/web_runner.rs b/crates/eframe/src/web/web_runner.rs index 099be7aebf4..c9449ab9988 100644 --- a/crates/eframe/src/web/web_runner.rs +++ b/crates/eframe/src/web/web_runner.rs @@ -2,12 +2,12 @@ use std::{cell::RefCell, rc::Rc}; use wasm_bindgen::prelude::*; -use crate::{epi, App}; +use crate::{App, epi}; use super::{ + AppRunner, PanicHandler, events::{self, ResizeObserverContext}, text_agent::TextAgent, - AppRunner, PanicHandler, }; /// This is how `eframe` runs your web application diff --git a/crates/egui-wgpu/src/capture.rs b/crates/egui-wgpu/src/capture.rs index 38595bb6fb7..d47a828b4bf 100644 --- a/crates/egui-wgpu/src/capture.rs +++ b/crates/egui-wgpu/src/capture.rs @@ -1,6 +1,6 @@ use egui::{UserData, ViewportId}; use epaint::ColorImage; -use std::sync::{mpsc, Arc}; +use std::sync::{Arc, mpsc}; use wgpu::{BindGroupLayout, MultisampleState, StoreOp}; /// A texture and a buffer for reading the rendered frame back to the cpu. @@ -196,7 +196,10 @@ impl CaptureState { wgpu::TextureFormat::Rgba8Unorm => [0, 1, 2, 3], wgpu::TextureFormat::Bgra8Unorm => [2, 1, 0, 3], _ => { - log::error!("Screen can't be captured unless the surface format is Rgba8Unorm or Bgra8Unorm. Current surface format is {:?}", format); + log::error!( + "Screen can't be captured unless the surface format is Rgba8Unorm or Bgra8Unorm. Current surface format is {:?}", + format + ); return; } }; diff --git a/crates/egui-wgpu/src/renderer.rs b/crates/egui-wgpu/src/renderer.rs index 7badefda479..73df09e43cc 100644 --- a/crates/egui-wgpu/src/renderer.rs +++ b/crates/egui-wgpu/src/renderer.rs @@ -3,7 +3,7 @@ use std::{borrow::Cow, num::NonZeroU64, ops::Range}; use ahash::HashMap; -use epaint::{emath::NumExt as _, PaintCallbackInfo, Primitive, Vertex}; +use epaint::{PaintCallbackInfo, Primitive, Vertex, emath::NumExt as _}; use wgpu::util::DeviceExt as _; @@ -909,7 +909,11 @@ impl Renderer { ); let Some(mut index_buffer_staging) = index_buffer_staging else { - panic!("Failed to create staging buffer for index data. Index count: {index_count}. Required index buffer size: {required_index_buffer_size}. Actual size {} and capacity: {} (bytes)", self.index_buffer.buffer.size(), self.index_buffer.capacity); + panic!( + "Failed to create staging buffer for index data. Index count: {index_count}. Required index buffer size: {required_index_buffer_size}. Actual size {} and capacity: {} (bytes)", + self.index_buffer.buffer.size(), + self.index_buffer.capacity + ); }; let mut index_offset = 0; @@ -948,7 +952,11 @@ impl Renderer { ); let Some(mut vertex_buffer_staging) = vertex_buffer_staging else { - panic!("Failed to create staging buffer for vertex data. Vertex count: {vertex_count}. Required vertex buffer size: {required_vertex_buffer_size}. Actual size {} and capacity: {} (bytes)", self.vertex_buffer.buffer.size(), self.vertex_buffer.capacity); + panic!( + "Failed to create staging buffer for vertex data. Vertex count: {vertex_count}. Required vertex buffer size: {required_vertex_buffer_size}. Actual size {} and capacity: {} (bytes)", + self.vertex_buffer.buffer.size(), + self.vertex_buffer.capacity + ); }; let mut vertex_offset = 0; diff --git a/crates/egui-wgpu/src/winit.rs b/crates/egui-wgpu/src/winit.rs index e0eafee71e2..cd02b59d89a 100644 --- a/crates/egui-wgpu/src/winit.rs +++ b/crates/egui-wgpu/src/winit.rs @@ -1,8 +1,8 @@ #![allow(clippy::missing_errors_doc)] #![allow(clippy::undocumented_unsafe_blocks)] -use crate::capture::{capture_channel, CaptureReceiver, CaptureSender, CaptureState}; -use crate::{renderer, RenderState, SurfaceErrorAction, WgpuConfiguration}; +use crate::capture::{CaptureReceiver, CaptureSender, CaptureState, capture_channel}; +use crate::{RenderState, SurfaceErrorAction, WgpuConfiguration, renderer}; use egui::{Context, Event, UserData, ViewportId, ViewportIdMap, ViewportIdSet}; use std::{num::NonZeroU32, sync::Arc}; @@ -220,7 +220,9 @@ impl Painter { } else if supported_alpha_modes.contains(&wgpu::CompositeAlphaMode::PostMultiplied) { wgpu::CompositeAlphaMode::PostMultiplied } else { - log::warn!("Transparent window was requested, but the active wgpu surface does not support a `CompositeAlphaMode` with transparency."); + log::warn!( + "Transparent window was requested, but the active wgpu surface does not support a `CompositeAlphaMode` with transparency." + ); wgpu::CompositeAlphaMode::Auto } } else { @@ -344,7 +346,9 @@ impl Painter { height_in_pixels, ); } else { - log::warn!("Ignoring window resize notification with no surface created via Painter::set_window()"); + log::warn!( + "Ignoring window resize notification with no surface created via Painter::set_window()" + ); } } diff --git a/crates/egui-winit/src/clipboard.rs b/crates/egui-winit/src/clipboard.rs index a0221294eff..cec4b43c2f0 100644 --- a/crates/egui-winit/src/clipboard.rs +++ b/crates/egui-winit/src/clipboard.rs @@ -123,7 +123,9 @@ impl Clipboard { return; } - log::error!("Copying images is not supported. Enable the 'clipboard' feature of `egui-winit` to enable it."); + log::error!( + "Copying images is not supported. Enable the 'clipboard' feature of `egui-winit` to enable it." + ); _ = image; } } diff --git a/crates/egui/src/animation_manager.rs b/crates/egui/src/animation_manager.rs index 15002141f0b..50f97e992b6 100644 --- a/crates/egui/src/animation_manager.rs +++ b/crates/egui/src/animation_manager.rs @@ -1,6 +1,6 @@ use crate::{ - emath::{remap_clamp, NumExt as _}, Id, IdMap, InputState, + emath::{NumExt as _, remap_clamp}, }; #[derive(Clone, Default)] diff --git a/crates/egui/src/callstack.rs b/crates/egui/src/callstack.rs index 03eeaf5fc6e..3fe0a7a59cf 100644 --- a/crates/egui/src/callstack.rs +++ b/crates/egui/src/callstack.rs @@ -204,12 +204,17 @@ fn shorten_source_file_path(path: &std::path::Path) -> String { #[test] fn test_shorten_path() { for (before, after) in [ - ("/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs", "tokio-1.24.1/src/runtime/runtime.rs"), + ( + "/Users/emilk/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.24.1/src/runtime/runtime.rs", + "tokio-1.24.1/src/runtime/runtime.rs", + ), ("crates/rerun/src/main.rs", "rerun/src/main.rs"), - ("/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs", "core/src/ops/function.rs"), + ( + "/rustc/d5a82bbd26e1ad8b7401f6a718a9c57c96905483/library/core/src/ops/function.rs", + "core/src/ops/function.rs", + ), ("/weird/path/file.rs", "/weird/path/file.rs"), - ] - { + ] { use std::str::FromStr as _; let before = std::path::PathBuf::from_str(before).unwrap(); assert_eq!(shorten_source_file_path(&before), after); diff --git a/crates/egui/src/containers/area.rs b/crates/egui/src/containers/area.rs index 0d21e8bdd55..d40df8358eb 100644 --- a/crates/egui/src/containers/area.rs +++ b/crates/egui/src/containers/area.rs @@ -5,8 +5,8 @@ use emath::GuiRounding as _; use crate::{ - emath, pos2, Align2, Context, Id, InnerResponse, LayerId, Layout, NumExt as _, Order, Pos2, - Rect, Response, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState, + Align2, Context, Id, InnerResponse, LayerId, Layout, NumExt as _, Order, Pos2, Rect, Response, + Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetRect, WidgetWithState, emath, pos2, }; /// State of an [`Area`] that is persisted between frames. diff --git a/crates/egui/src/containers/collapsing_header.rs b/crates/egui/src/containers/collapsing_header.rs index 66e024f0b3c..3afb776823c 100644 --- a/crates/egui/src/containers/collapsing_header.rs +++ b/crates/egui/src/containers/collapsing_header.rs @@ -1,9 +1,9 @@ use std::hash::Hash; use crate::{ - emath, epaint, pos2, remap, remap_clamp, vec2, Context, Id, InnerResponse, NumExt as _, Rect, - Response, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, - WidgetInfo, WidgetText, WidgetType, + Context, Id, InnerResponse, NumExt as _, Rect, Response, Sense, Stroke, TextStyle, + TextWrapMode, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, WidgetInfo, WidgetText, WidgetType, + emath, epaint, pos2, remap, remap_clamp, vec2, }; use emath::GuiRounding as _; use epaint::{Shape, StrokeKind}; diff --git a/crates/egui/src/containers/combo_box.rs b/crates/egui/src/containers/combo_box.rs index 3ae8344bae1..fc5f3390535 100644 --- a/crates/egui/src/containers/combo_box.rs +++ b/crates/egui/src/containers/combo_box.rs @@ -1,9 +1,9 @@ use epaint::Shape; use crate::{ - epaint, style::StyleModifier, style::WidgetVisuals, vec2, Align2, Context, Id, InnerResponse, - NumExt as _, Painter, Popup, PopupCloseBehavior, Rect, Response, ScrollArea, Sense, Stroke, - TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo, WidgetText, WidgetType, + Align2, Context, Id, InnerResponse, NumExt as _, Painter, Popup, PopupCloseBehavior, Rect, + Response, ScrollArea, Sense, Stroke, TextStyle, TextWrapMode, Ui, UiBuilder, Vec2, WidgetInfo, + WidgetText, WidgetType, epaint, style::StyleModifier, style::WidgetVisuals, vec2, }; #[expect(unused_imports)] // Documentation diff --git a/crates/egui/src/containers/frame.rs b/crates/egui/src/containers/frame.rs index 1fdbbca922d..d4b67769381 100644 --- a/crates/egui/src/containers/frame.rs +++ b/crates/egui/src/containers/frame.rs @@ -1,8 +1,8 @@ //! Frame container use crate::{ - epaint, layers::ShapeIdx, InnerResponse, Response, Sense, Style, Ui, UiBuilder, UiKind, - UiStackInfo, + InnerResponse, Response, Sense, Style, Ui, UiBuilder, UiKind, UiStackInfo, epaint, + layers::ShapeIdx, }; use epaint::{Color32, CornerRadius, Margin, MarginF32, Rect, Shadow, Shape, Stroke}; @@ -143,7 +143,8 @@ pub struct Frame { #[test] fn frame_size() { assert_eq!( - std::mem::size_of::(), 32, + std::mem::size_of::(), + 32, "Frame changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it." ); assert!( diff --git a/crates/egui/src/containers/menu.rs b/crates/egui/src/containers/menu.rs index 4fe06477d87..d07d3ab6c43 100644 --- a/crates/egui/src/containers/menu.rs +++ b/crates/egui/src/containers/menu.rs @@ -3,7 +3,7 @@ use crate::{ Button, Color32, Context, Frame, Id, InnerResponse, IntoAtoms, Layout, Popup, PopupCloseBehavior, Response, Style, Ui, UiBuilder, UiKind, UiStack, UiStackInfo, Widget as _, }; -use emath::{vec2, Align, RectAlign, Vec2}; +use emath::{Align, RectAlign, Vec2, vec2}; use epaint::Stroke; /// Apply a menu style to the [`Style`]. diff --git a/crates/egui/src/containers/panel.rs b/crates/egui/src/containers/panel.rs index db0e8a7f964..2869f598cf4 100644 --- a/crates/egui/src/containers/panel.rs +++ b/crates/egui/src/containers/panel.rs @@ -18,8 +18,8 @@ use emath::GuiRounding as _; use crate::{ - lerp, vec2, Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt as _, - Rangef, Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, + Align, Context, CursorIcon, Frame, Id, InnerResponse, LayerId, Layout, NumExt as _, Rangef, + Rect, Sense, Stroke, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, lerp, vec2, }; fn animate_expansion(ctx: &Context, id: Id, is_expanded: bool) -> f32 { diff --git a/crates/egui/src/containers/popup.rs b/crates/egui/src/containers/popup.rs index c40578bc6fc..434747cdad4 100644 --- a/crates/egui/src/containers/popup.rs +++ b/crates/egui/src/containers/popup.rs @@ -1,10 +1,10 @@ -use crate::containers::menu::{menu_style, MenuConfig, MenuState}; +use crate::containers::menu::{MenuConfig, MenuState, menu_style}; use crate::style::StyleModifier; use crate::{ Area, AreaState, Context, Frame, Id, InnerResponse, Key, LayerId, Layout, Order, Response, Sense, Ui, UiKind, UiStackInfo, }; -use emath::{vec2, Align, Pos2, Rect, RectAlign, Vec2}; +use emath::{Align, Pos2, Rect, RectAlign, Vec2, vec2}; use std::iter::once; /// What should we anchor the popup to? diff --git a/crates/egui/src/containers/resize.rs b/crates/egui/src/containers/resize.rs index fe386164665..f7522e02079 100644 --- a/crates/egui/src/containers/resize.rs +++ b/crates/egui/src/containers/resize.rs @@ -1,6 +1,6 @@ use crate::{ - pos2, vec2, Align2, Color32, Context, CursorIcon, Id, NumExt as _, Rect, Response, Sense, - Shape, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, + Align2, Color32, Context, CursorIcon, Id, NumExt as _, Rect, Response, Sense, Shape, Ui, + UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, pos2, vec2, }; #[derive(Clone, Copy, Debug)] diff --git a/crates/egui/src/containers/scene.rs b/crates/egui/src/containers/scene.rs index aaca3729108..4c8c9f64b78 100644 --- a/crates/egui/src/containers/scene.rs +++ b/crates/egui/src/containers/scene.rs @@ -3,8 +3,8 @@ use core::f32; use emath::{GuiRounding as _, Pos2}; use crate::{ - emath::TSTransform, InnerResponse, LayerId, PointerButton, Rangef, Rect, Response, Sense, Ui, - UiBuilder, Vec2, + InnerResponse, LayerId, PointerButton, Rangef, Rect, Response, Sense, Ui, UiBuilder, Vec2, + emath::TSTransform, }; /// Creates a transformation that fits a given scene rectangle into the available screen size. diff --git a/crates/egui/src/containers/scroll_area.rs b/crates/egui/src/containers/scroll_area.rs index 9e4d60d3b3b..45599ac8c3c 100644 --- a/crates/egui/src/containers/scroll_area.rs +++ b/crates/egui/src/containers/scroll_area.rs @@ -3,8 +3,8 @@ use std::ops::{Add, AddAssign, BitOr, BitOrAssign}; use crate::{ - emath, epaint, lerp, pass_state, pos2, remap, remap_clamp, Context, CursorIcon, Id, - NumExt as _, Pos2, Rangef, Rect, Sense, Ui, UiBuilder, UiKind, UiStackInfo, Vec2, Vec2b, + Context, CursorIcon, Id, NumExt as _, Pos2, Rangef, Rect, Sense, Ui, UiBuilder, UiKind, + UiStackInfo, Vec2, Vec2b, emath, epaint, lerp, pass_state, pos2, remap, remap_clamp, }; #[derive(Clone, Copy, Debug)] diff --git a/crates/egui/src/containers/window.rs b/crates/egui/src/containers/window.rs index b34332ea180..e93b046e589 100644 --- a/crates/egui/src/containers/window.rs +++ b/crates/egui/src/containers/window.rs @@ -9,7 +9,7 @@ use crate::collapsing_header::CollapsingState; use crate::*; use super::scroll_area::{ScrollBarVisibility, ScrollSource}; -use super::{area, resize, Area, Frame, Resize, ScrollArea}; +use super::{Area, Frame, Resize, ScrollArea, area, resize}; /// Builder for a floating window which can be dragged, closed, collapsed, resized and scrolled (off by default). /// diff --git a/crates/egui/src/context.rs b/crates/egui/src/context.rs index de0a7e2e48d..54ae490366f 100644 --- a/crates/egui/src/context.rs +++ b/crates/egui/src/context.rs @@ -4,16 +4,23 @@ use std::{borrow::Cow, cell::RefCell, panic::Location, sync::Arc, time::Duration use emath::{GuiRounding as _, OrderedFloat}; use epaint::{ + ClippedPrimitive, ClippedShape, Color32, ImageData, ImageDelta, Pos2, Rect, StrokeKind, + TessellationOptions, TextureAtlas, TextureId, Vec2, emath::{self, TSTransform}, mutex::RwLock, stats::PaintStats, tessellator, text::{FontInsert, FontPriority, Fonts}, - vec2, ClippedPrimitive, ClippedShape, Color32, ImageData, ImageDelta, Pos2, Rect, StrokeKind, - TessellationOptions, TextureAtlas, TextureId, Vec2, + vec2, }; use crate::{ + Align2, CursorIcon, DeferredViewportUiCallback, FontDefinitions, Grid, Id, ImmediateViewport, + ImmediateViewportRendererCallback, Key, KeyboardShortcut, Label, LayerId, Memory, + ModifierNames, Modifiers, NumExt as _, Order, Painter, RawInput, Response, RichText, + ScrollArea, Sense, Style, TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder, + ViewportCommand, ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput, + Widget as _, WidgetRect, WidgetText, animation_manager::AnimationManager, containers::{self, area::AreaState}, data::output::PlatformOutput, @@ -29,12 +36,6 @@ use crate::{ resize, response, scroll_area, util::IdTypeMap, viewport::ViewportClass, - Align2, CursorIcon, DeferredViewportUiCallback, FontDefinitions, Grid, Id, ImmediateViewport, - ImmediateViewportRendererCallback, Key, KeyboardShortcut, Label, LayerId, Memory, - ModifierNames, Modifiers, NumExt as _, Order, Painter, RawInput, Response, RichText, - ScrollArea, Sense, Style, TextStyle, TextureHandle, TextureOptions, Ui, ViewportBuilder, - ViewportCommand, ViewportId, ViewportIdMap, ViewportIdPair, ViewportIdSet, ViewportOutput, - Widget as _, WidgetRect, WidgetText, }; #[cfg(feature = "accesskit")] @@ -860,7 +861,10 @@ impl Context { if max_passes <= output.platform_output.num_completed_passes { #[cfg(feature = "log")] - log::debug!("Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}", output.platform_output.request_discard_reasons); + log::debug!( + "Ignoring call request_discard, because max_passes={max_passes}. Requested from {:?}", + output.platform_output.request_discard_reasons + ); break; } @@ -2353,7 +2357,9 @@ impl Context { // If you see this message, it means we've been paying the cost of multi-pass for multiple frames in a row. // This is likely a bug. `request_discard` should only be called in rare situations, when some layout changes. - let mut warning = format!("egui PERF WARNING: request_discard has been called {num_multipass_in_row} frames in a row"); + let mut warning = format!( + "egui PERF WARNING: request_discard has been called {num_multipass_in_row} frames in a row" + ); self.viewport(|vp| { for reason in &vp.output.request_discard_reasons { warning += &format!("\n {reason}"); diff --git a/crates/egui/src/data/input.rs b/crates/egui/src/data/input.rs index 1e2580678d3..05b93616d44 100644 --- a/crates/egui/src/data/input.rs +++ b/crates/egui/src/data/input.rs @@ -3,8 +3,8 @@ use epaint::ColorImage; use crate::{ - emath::{Pos2, Rect, Vec2}, Key, Theme, ViewportId, ViewportIdMap, + emath::{Pos2, Rect, Vec2}, }; /// What the integrations provides to egui at the start of each frame. diff --git a/crates/egui/src/debug_text.rs b/crates/egui/src/debug_text.rs index bb9487bd32f..f487e795fe4 100644 --- a/crates/egui/src/debug_text.rs +++ b/crates/egui/src/debug_text.rs @@ -6,7 +6,7 @@ //! to get callbacks on certain events ([`Context::on_begin_pass`], [`Context::on_end_pass`]). use crate::{ - text, Align, Align2, Color32, Context, FontFamily, FontId, Id, Rect, Shape, Vec2, WidgetText, + Align, Align2, Color32, Context, FontFamily, FontId, Id, Rect, Shape, Vec2, WidgetText, text, }; /// Register this plugin on the given egui context, diff --git a/crates/egui/src/grid.rs b/crates/egui/src/grid.rs index dbc22a09dea..31f9e7a7108 100644 --- a/crates/egui/src/grid.rs +++ b/crates/egui/src/grid.rs @@ -1,8 +1,8 @@ use emath::GuiRounding as _; use crate::{ - vec2, Align2, Color32, Context, Id, InnerResponse, NumExt as _, Painter, Rect, Region, Style, - Ui, UiBuilder, Vec2, + Align2, Color32, Context, Id, InnerResponse, NumExt as _, Painter, Rect, Region, Style, Ui, + UiBuilder, Vec2, vec2, }; #[cfg(debug_assertions)] diff --git a/crates/egui/src/hit_test.rs b/crates/egui/src/hit_test.rs index 2f0edcfaf61..f253a1dfec2 100644 --- a/crates/egui/src/hit_test.rs +++ b/crates/egui/src/hit_test.rs @@ -2,7 +2,7 @@ use ahash::HashMap; use emath::TSTransform; -use crate::{ahash, emath, id::IdSet, LayerId, Pos2, Rect, Sense, WidgetRect, WidgetRects}; +use crate::{LayerId, Pos2, Rect, Sense, WidgetRect, WidgetRects, ahash, emath, id::IdSet}; /// Result of a hit-test against [`WidgetRects`]. /// @@ -466,7 +466,7 @@ fn should_prioritize_hits_on_back(back: Rect, front: Rect) -> bool { #[cfg(test)] mod tests { - use emath::{pos2, vec2, Rect}; + use emath::{Rect, pos2, vec2}; use crate::{Id, Sense}; diff --git a/crates/egui/src/input_state/mod.rs b/crates/egui/src/input_state/mod.rs index 7fd07316746..d87bd5669ad 100644 --- a/crates/egui/src/input_state/mod.rs +++ b/crates/egui/src/input_state/mod.rs @@ -1,11 +1,11 @@ mod touch_state; use crate::data::input::{ - Event, EventFilter, KeyboardShortcut, Modifiers, MouseWheelUnit, PointerButton, RawInput, - TouchDeviceId, ViewportInfo, NUM_POINTER_BUTTONS, + Event, EventFilter, KeyboardShortcut, Modifiers, MouseWheelUnit, NUM_POINTER_BUTTONS, + PointerButton, RawInput, TouchDeviceId, ViewportInfo, }; use crate::{ - emath::{vec2, NumExt as _, Pos2, Rect, Vec2}, + emath::{NumExt as _, Pos2, Rect, Vec2, vec2}, util::History, }; use std::{ diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index b4c789a8e40..2cb6d2ae094 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -1,9 +1,9 @@ use std::{collections::BTreeMap, fmt::Debug}; use crate::{ - data::input::TouchDeviceId, - emath::{normalized_angle, Pos2, Vec2}, Event, RawInput, TouchId, TouchPhase, + data::input::TouchDeviceId, + emath::{Pos2, Vec2, normalized_angle}, }; /// All you probably need to know about a multi-touch gesture. diff --git a/crates/egui/src/interaction.rs b/crates/egui/src/interaction.rs index b6b63e19d47..9cd76b3a0e4 100644 --- a/crates/egui/src/interaction.rs +++ b/crates/egui/src/interaction.rs @@ -1,6 +1,6 @@ //! How mouse and touch interzcts with widgets. -use crate::{hit_test, id, input_state, memory, Id, InputState, Key, WidgetRects}; +use crate::{Id, InputState, Key, WidgetRects, hit_test, id, input_state, memory}; use self::{hit_test::WidgetHits, id::IdSet, input_state::PointerEvent, memory::InteractionState}; diff --git a/crates/egui/src/introspection.rs b/crates/egui/src/introspection.rs index 8826eca79bf..fa8caa3c880 100644 --- a/crates/egui/src/introspection.rs +++ b/crates/egui/src/introspection.rs @@ -1,7 +1,7 @@ //! Showing UI:s for egui/epaint types. use crate::{ - epaint, memory, pos2, remap_clamp, vec2, Color32, CursorIcon, FontFamily, FontId, Label, Mesh, - NumExt as _, Rect, Response, Sense, Shape, Slider, TextStyle, TextWrapMode, Ui, Widget, + Color32, CursorIcon, FontFamily, FontId, Label, Mesh, NumExt as _, Rect, Response, Sense, + Shape, Slider, TextStyle, TextWrapMode, Ui, Widget, epaint, memory, pos2, remap_clamp, vec2, }; pub fn font_family_ui(ui: &mut Ui, font_family: &mut FontFamily) { diff --git a/crates/egui/src/layers.rs b/crates/egui/src/layers.rs index 81a60812ece..927ffc36b16 100644 --- a/crates/egui/src/layers.rs +++ b/crates/egui/src/layers.rs @@ -1,8 +1,8 @@ //! Handles paint layers, i.e. how things //! are sometimes painted behind or in front of other things. -use crate::{ahash, epaint, Id, IdMap, Rect}; -use epaint::{emath::TSTransform, ClippedShape, Shape}; +use crate::{Id, IdMap, Rect, ahash, epaint}; +use epaint::{ClippedShape, Shape, emath::TSTransform}; /// Different layer categories #[derive(Clone, Copy, Debug, Hash, Eq, PartialEq, Ord, PartialOrd)] diff --git a/crates/egui/src/layout.rs b/crates/egui/src/layout.rs index a0665246bfa..3064d0d87fc 100644 --- a/crates/egui/src/layout.rs +++ b/crates/egui/src/layout.rs @@ -1,8 +1,8 @@ use emath::GuiRounding as _; use crate::{ - emath::{pos2, vec2, Align2, NumExt as _, Pos2, Rect, Vec2}, Align, + emath::{Align2, NumExt as _, Pos2, Rect, Vec2, pos2, vec2}, }; const INFINITY: f32 = f32::INFINITY; diff --git a/crates/egui/src/lib.rs b/crates/egui/src/lib.rs index fa390dbc771..b4daa932672 100644 --- a/crates/egui/src/lib.rs +++ b/crates/egui/src/lib.rs @@ -463,22 +463,21 @@ pub use epaint::emath; pub use ecolor::hex_color; pub use ecolor::{Color32, Rgba}; pub use emath::{ - lerp, pos2, remap, remap_clamp, vec2, Align, Align2, NumExt, Pos2, Rangef, Rect, RectAlign, - Vec2, Vec2b, + Align, Align2, NumExt, Pos2, Rangef, Rect, RectAlign, Vec2, Vec2b, lerp, pos2, remap, + remap_clamp, vec2, }; pub use epaint::{ - mutex, + ClippedPrimitive, ColorImage, CornerRadius, FontImage, ImageData, Margin, Mesh, PaintCallback, + PaintCallbackInfo, Shadow, Shape, Stroke, StrokeKind, TextureHandle, TextureId, mutex, text::{FontData, FontDefinitions, FontFamily, FontId, FontTweak}, textures::{TextureFilter, TextureOptions, TextureWrapMode, TexturesDelta}, - ClippedPrimitive, ColorImage, CornerRadius, FontImage, ImageData, Margin, Mesh, PaintCallback, - PaintCallbackInfo, Shadow, Shape, Stroke, StrokeKind, TextureHandle, TextureId, }; pub mod text { pub use crate::text_selection::CCursorRange; pub use epaint::text::{ - cursor::CCursor, FontData, FontDefinitions, FontFamily, Fonts, Galley, LayoutJob, - LayoutSection, TextFormat, TextWrapping, TAB_SIZE, + FontData, FontDefinitions, FontFamily, Fonts, Galley, LayoutJob, LayoutSection, TAB_SIZE, + TextFormat, TextWrapping, cursor::CCursor, }; } @@ -487,12 +486,12 @@ pub use self::{ containers::*, context::{Context, RepaintCause, RequestRepaintInfo}, data::{ + Key, UserData, input::*, output::{ self, CursorIcon, FullOutput, OpenUrl, OutputCommand, PlatformOutput, UserAttentionType, WidgetInfo, }, - Key, UserData, }, drag_and_drop::DragAndDrop, epaint::text::TextWrapMode, diff --git a/crates/egui/src/load.rs b/crates/egui/src/load.rs index 9c9df5a9c42..43aa1785e33 100644 --- a/crates/egui/src/load.rs +++ b/crates/egui/src/load.rs @@ -65,7 +65,7 @@ use std::{ use ahash::HashMap; use emath::{Float as _, OrderedFloat}; -use epaint::{mutex::Mutex, textures::TextureOptions, ColorImage, TextureHandle, TextureId, Vec2}; +use epaint::{ColorImage, TextureHandle, TextureId, Vec2, mutex::Mutex, textures::TextureOptions}; use crate::Context; diff --git a/crates/egui/src/load/bytes_loader.rs b/crates/egui/src/load/bytes_loader.rs index 5f3e0d3bca3..9f0c60356ae 100644 --- a/crates/egui/src/load/bytes_loader.rs +++ b/crates/egui/src/load/bytes_loader.rs @@ -1,6 +1,6 @@ use super::{ - generate_loader_id, Bytes, BytesLoadResult, BytesLoader, BytesPoll, Context, Cow, HashMap, - LoadError, Mutex, + Bytes, BytesLoadResult, BytesLoader, BytesPoll, Context, Cow, HashMap, LoadError, Mutex, + generate_loader_id, }; /// Maps URI:s to [`Bytes`], e.g. found with `include_bytes!`. diff --git a/crates/egui/src/memory/mod.rs b/crates/egui/src/memory/mod.rs index 9bf482b830b..53d9172b0a1 100644 --- a/crates/egui/src/memory/mod.rs +++ b/crates/egui/src/memory/mod.rs @@ -6,8 +6,8 @@ use ahash::{HashMap, HashSet}; use epaint::emath::TSTransform; use crate::{ - area, vec2, EventFilter, Id, IdMap, LayerId, Order, Pos2, Rangef, RawInput, Rect, Style, Vec2, - ViewportId, ViewportIdMap, ViewportIdSet, + EventFilter, Id, IdMap, LayerId, Order, Pos2, Rangef, RawInput, Rect, Style, Vec2, ViewportId, + ViewportIdMap, ViewportIdSet, area, vec2, }; mod theme; @@ -377,8 +377,8 @@ impl Options { reduce_texture_memory, } = self; - use crate::containers::CollapsingHeader; use crate::Widget as _; + use crate::containers::CollapsingHeader; CollapsingHeader::new("⚙ Options") .default_open(false) @@ -1250,8 +1250,11 @@ impl Areas { /// /// The two layers must have the same [`LayerId::order`]. pub fn set_sublayer(&mut self, parent: LayerId, child: LayerId) { - debug_assert_eq!(parent.order, child.order, - "DEBUG ASSERT: Trying to set sublayers across layers of different order ({:?}, {:?}), which is currently undefined behavior in egui", parent.order, child.order); + debug_assert_eq!( + parent.order, child.order, + "DEBUG ASSERT: Trying to set sublayers across layers of different order ({:?}, {:?}), which is currently undefined behavior in egui", + parent.order, child.order + ); self.sublayers.entry(parent).or_default().insert(child); diff --git a/crates/egui/src/memory/theme.rs b/crates/egui/src/memory/theme.rs index 4a63ecd56f2..dd4d3d6f9e4 100644 --- a/crates/egui/src/memory/theme.rs +++ b/crates/egui/src/memory/theme.rs @@ -30,11 +30,7 @@ impl Theme { /// Chooses between [`Self::Dark`] or [`Self::Light`] based on a boolean value. pub fn from_dark_mode(dark_mode: bool) -> Self { - if dark_mode { - Self::Dark - } else { - Self::Light - } + if dark_mode { Self::Dark } else { Self::Light } } } diff --git a/crates/egui/src/menu.rs b/crates/egui/src/menu.rs index 9863f3941e0..99bbd450b8d 100644 --- a/crates/egui/src/menu.rs +++ b/crates/egui/src/menu.rs @@ -17,14 +17,13 @@ //! ``` use super::{ - style::WidgetVisuals, Align, Context, Id, InnerResponse, PointerState, Pos2, Rect, Response, - Sense, TextStyle, Ui, Vec2, + Align, Context, Id, InnerResponse, PointerState, Pos2, Rect, Response, Sense, TextStyle, Ui, + Vec2, style::WidgetVisuals, }; use crate::{ - epaint, vec2, - widgets::{Button, ImageButton}, Align2, Area, Color32, Frame, Key, LayerId, Layout, NumExt as _, Order, Stroke, Style, - TextWrapMode, UiKind, WidgetText, + TextWrapMode, UiKind, WidgetText, epaint, vec2, + widgets::{Button, ImageButton}, }; use epaint::mutex::RwLock; use std::sync::Arc; diff --git a/crates/egui/src/os.rs b/crates/egui/src/os.rs index 283e33863d3..a9b4a874c1e 100644 --- a/crates/egui/src/os.rs +++ b/crates/egui/src/os.rs @@ -71,7 +71,8 @@ impl OperatingSystem { #[cfg(feature = "log")] log::warn!( "egui: Failed to guess operating system from User-Agent {:?}. Please file an issue at https://github.com/emilk/egui/issues", - user_agent); + user_agent + ); Self::Unknown } diff --git a/crates/egui/src/painter.rs b/crates/egui/src/painter.rs index c17fbb272ef..373142f6162 100644 --- a/crates/egui/src/painter.rs +++ b/crates/egui/src/painter.rs @@ -2,14 +2,14 @@ use std::sync::Arc; use emath::GuiRounding as _; use epaint::{ - text::{Fonts, Galley, LayoutJob}, CircleShape, ClippedShape, CornerRadius, PathStroke, RectShape, Shape, Stroke, StrokeKind, + text::{Fonts, Galley, LayoutJob}, }; use crate::{ + Color32, Context, FontId, emath::{Align2, Pos2, Rangef, Rect, Vec2}, layers::{LayerId, PaintList, ShapeIdx}, - Color32, Context, FontId, }; /// Helper to paint shapes and text to a specific region on a specific layer. diff --git a/crates/egui/src/pass_state.rs b/crates/egui/src/pass_state.rs index 1f629253c4b..079bb4eb0c6 100644 --- a/crates/egui/src/pass_state.rs +++ b/crates/egui/src/pass_state.rs @@ -1,9 +1,9 @@ use ahash::HashMap; -use crate::{id::IdSet, style, Align, Id, IdMap, LayerId, Rangef, Rect, Vec2, WidgetRects}; +use crate::{Align, Id, IdMap, LayerId, Rangef, Rect, Vec2, WidgetRects, id::IdSet, style}; #[cfg(debug_assertions)] -use crate::{pos2, Align2, Color32, FontId, NumExt as _, Painter}; +use crate::{Align2, Color32, FontId, NumExt as _, Painter, pos2}; /// Reset at the start of each frame. #[derive(Clone, Debug, Default)] diff --git a/crates/egui/src/placer.rs b/crates/egui/src/placer.rs index 6ffe07ed693..6a5d31be01a 100644 --- a/crates/egui/src/placer.rs +++ b/crates/egui/src/placer.rs @@ -1,4 +1,4 @@ -use crate::{grid, vec2, Layout, Painter, Pos2, Rect, Region, Vec2}; +use crate::{Layout, Painter, Pos2, Rect, Region, Vec2, grid, vec2}; #[cfg(debug_assertions)] use crate::{Align2, Color32, Stroke}; diff --git a/crates/egui/src/response.rs b/crates/egui/src/response.rs index b54cb10e0e8..d9dc61c3627 100644 --- a/crates/egui/src/response.rs +++ b/crates/egui/src/response.rs @@ -1,9 +1,10 @@ use std::{any::Any, sync::Arc}; use crate::{ + Context, CursorIcon, Id, LayerId, PointerButton, Popup, PopupKind, Sense, Tooltip, Ui, + WidgetRect, WidgetText, emath::{Align, Pos2, Rect, Vec2}, - pass_state, Context, CursorIcon, Id, LayerId, PointerButton, Popup, PopupKind, Sense, Tooltip, - Ui, WidgetRect, WidgetText, + pass_state, }; // ---------------------------------------------------------------------------- diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 7b73edbb9ad..35426948333 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -3,14 +3,14 @@ #![allow(clippy::if_same_then_else)] use emath::Align; -use epaint::{text::FontTweak, CornerRadius, Shadow, Stroke}; +use epaint::{CornerRadius, Shadow, Stroke, text::FontTweak}; use std::{collections::BTreeMap, ops::RangeInclusive, sync::Arc}; use crate::{ - ecolor::Color32, - emath::{pos2, vec2, Rangef, Rect, Vec2}, ComboBox, CursorIcon, FontFamily, FontId, Grid, Margin, Response, RichText, TextWrapMode, WidgetText, + ecolor::Color32, + emath::{Rangef, Rect, Vec2, pos2, vec2}, }; /// How to format numbers in e.g. a [`crate::DragValue`]. @@ -1557,8 +1557,8 @@ impl Default for Widgets { // ---------------------------------------------------------------------------- use crate::{ - widgets::{reset_button, DragValue, Slider, Widget}, Ui, + widgets::{DragValue, Slider, Widget, reset_button}, }; impl Style { diff --git a/crates/egui/src/text_selection/accesskit_text.rs b/crates/egui/src/text_selection/accesskit_text.rs index e04a54d1824..b189955429e 100644 --- a/crates/egui/src/text_selection/accesskit_text.rs +++ b/crates/egui/src/text_selection/accesskit_text.rs @@ -2,7 +2,7 @@ use emath::TSTransform; use crate::{Context, Galley, Id}; -use super::{text_cursor_state::is_word_char, CCursorRange}; +use super::{CCursorRange, text_cursor_state::is_word_char}; /// Update accesskit with the current text state. pub fn update_accesskit_for_text_widget( diff --git a/crates/egui/src/text_selection/cursor_range.rs b/crates/egui/src/text_selection/cursor_range.rs index 05351e0ac8e..10980c581d9 100644 --- a/crates/egui/src/text_selection/cursor_range.rs +++ b/crates/egui/src/text_selection/cursor_range.rs @@ -1,6 +1,6 @@ -use epaint::{text::cursor::CCursor, Galley}; +use epaint::{Galley, text::cursor::CCursor}; -use crate::{os::OperatingSystem, Event, Id, Key, Modifiers}; +use crate::{Event, Id, Key, Modifiers, os::OperatingSystem}; use super::text_cursor_state::{ccursor_next_word, ccursor_previous_word, slice_char_range}; diff --git a/crates/egui/src/text_selection/label_text_selection.rs b/crates/egui/src/text_selection/label_text_selection.rs index a315c2354a7..ffbc7ae304c 100644 --- a/crates/egui/src/text_selection/label_text_selection.rs +++ b/crates/egui/src/text_selection/label_text_selection.rs @@ -3,14 +3,14 @@ use std::sync::Arc; use emath::TSTransform; use crate::{ - layers::ShapeIdx, text::CCursor, text_selection::CCursorRange, Context, CursorIcon, Event, - Galley, Id, LayerId, Pos2, Rect, Response, Ui, + Context, CursorIcon, Event, Galley, Id, LayerId, Pos2, Rect, Response, Ui, layers::ShapeIdx, + text::CCursor, text_selection::CCursorRange, }; use super::{ - text_cursor_state::cursor_rect, - visuals::{paint_text_selection, RowVertexIndices}, TextCursorState, + text_cursor_state::cursor_rect, + visuals::{RowVertexIndices, paint_text_selection}, }; /// Turn on to help debug this diff --git a/crates/egui/src/text_selection/text_cursor_state.rs b/crates/egui/src/text_selection/text_cursor_state.rs index d2158c6bd65..2a02e457752 100644 --- a/crates/egui/src/text_selection/text_cursor_state.rs +++ b/crates/egui/src/text_selection/text_cursor_state.rs @@ -1,9 +1,9 @@ //! Text cursor changes/interaction, without modifying the text. -use epaint::text::{cursor::CCursor, Galley}; +use epaint::text::{Galley, cursor::CCursor}; use unicode_segmentation::UnicodeSegmentation as _; -use crate::{epaint, NumExt as _, Rect, Response, Ui}; +use crate::{NumExt as _, Rect, Response, Ui, epaint}; use super::CCursorRange; diff --git a/crates/egui/src/text_selection/visuals.rs b/crates/egui/src/text_selection/visuals.rs index deee5690bce..e3054b19ded 100644 --- a/crates/egui/src/text_selection/visuals.rs +++ b/crates/egui/src/text_selection/visuals.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use crate::{pos2, vec2, Galley, Painter, Rect, Ui, Visuals}; +use crate::{Galley, Painter, Rect, Ui, Visuals, pos2, vec2}; use super::CCursorRange; diff --git a/crates/egui/src/ui.rs b/crates/egui/src/ui.rs index bc2ed860df2..0abd9c054e7 100644 --- a/crates/egui/src/ui.rs +++ b/crates/egui/src/ui.rs @@ -5,11 +5,15 @@ use emath::GuiRounding as _; use epaint::mutex::RwLock; use std::{any::Any, hash::Hash, sync::Arc}; -use crate::close_tag::ClosableTag; -use crate::containers::menu; #[cfg(debug_assertions)] use crate::Stroke; +use crate::close_tag::ClosableTag; +use crate::containers::menu; use crate::{ + Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, IntoAtoms, + LayerId, Memory, Order, Painter, PlatformOutput, Pos2, Rangef, Rect, Response, Rgba, RichText, + Sense, Style, TextStyle, TextWrapMode, UiBuilder, UiKind, UiStack, UiStackInfo, Vec2, + WidgetRect, WidgetText, containers::{CollapsingHeader, CollapsingResponse, Frame}, ecolor::Hsva, emath, epaint, @@ -22,13 +26,9 @@ use crate::{ util::IdTypeMap, vec2, widgets, widgets::{ - color_picker, Button, Checkbox, DragValue, Hyperlink, Image, ImageSource, Label, Link, - RadioButton, SelectableLabel, Separator, Spinner, TextEdit, Widget, + Button, Checkbox, DragValue, Hyperlink, Image, ImageSource, Label, Link, RadioButton, + SelectableLabel, Separator, Spinner, TextEdit, Widget, color_picker, }, - Align, Color32, Context, CursorIcon, DragAndDrop, Id, InnerResponse, InputState, IntoAtoms, - LayerId, Memory, Order, Painter, PlatformOutput, Pos2, Rangef, Rect, Response, Rgba, RichText, - Sense, Style, TextStyle, TextWrapMode, UiBuilder, UiKind, UiStack, UiStackInfo, Vec2, - WidgetRect, WidgetText, }; // ---------------------------------------------------------------------------- diff --git a/crates/egui/src/ui_builder.rs b/crates/egui/src/ui_builder.rs index 4aade7d6406..fcb389fd9d4 100644 --- a/crates/egui/src/ui_builder.rs +++ b/crates/egui/src/ui_builder.rs @@ -1,8 +1,8 @@ use std::{hash::Hash, sync::Arc}; -use crate::close_tag::ClosableTag; #[expect(unused_imports)] // Used for doclinks use crate::Ui; +use crate::close_tag::ClosableTag; use crate::{Id, LayerId, Layout, Rect, Sense, Style, UiStackInfo}; /// Build a [`Ui`] as the child of another [`Ui`]. diff --git a/crates/egui/src/widget_text.rs b/crates/egui/src/widget_text.rs index d0edb6a26d2..75bf36d83f8 100644 --- a/crates/egui/src/widget_text.rs +++ b/crates/egui/src/widget_text.rs @@ -4,8 +4,8 @@ use std::fmt::Formatter; use std::{borrow::Cow, sync::Arc}; use crate::{ - text::{LayoutJob, TextWrapping}, Align, Color32, FontFamily, FontSelection, Galley, Style, TextStyle, TextWrapMode, Ui, Visuals, + text::{LayoutJob, TextWrapping}, }; /// Text and optional style choices for it. diff --git a/crates/egui/src/widgets/checkbox.rs b/crates/egui/src/widgets/checkbox.rs index f7498de5af6..c90cca292a8 100644 --- a/crates/egui/src/widgets/checkbox.rs +++ b/crates/egui/src/widgets/checkbox.rs @@ -1,6 +1,6 @@ use crate::{ - epaint, pos2, Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Shape, Ui, - Vec2, Widget, WidgetInfo, WidgetType, + Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Shape, Ui, Vec2, Widget, + WidgetInfo, WidgetType, epaint, pos2, }; // TODO(emilk): allow checkbox without a text label diff --git a/crates/egui/src/widgets/color_picker.rs b/crates/egui/src/widgets/color_picker.rs index ebcd45b2761..f8605beafb0 100644 --- a/crates/egui/src/widgets/color_picker.rs +++ b/crates/egui/src/widgets/color_picker.rs @@ -2,12 +2,13 @@ use crate::util::fixed_cache::FixedCache; use crate::{ - epaint, lerp, remap_clamp, Context, DragValue, Id, Painter, Popup, PopupCloseBehavior, - Response, Sense, Ui, Widget as _, WidgetInfo, WidgetType, + Context, DragValue, Id, Painter, Popup, PopupCloseBehavior, Response, Sense, Ui, Widget as _, + WidgetInfo, WidgetType, epaint, lerp, remap_clamp, }; use epaint::{ + Mesh, Rect, Shape, Stroke, StrokeKind, Vec2, ecolor::{Color32, Hsva, HsvaGamma, Rgba}, - pos2, vec2, Mesh, Rect, Shape, Stroke, StrokeKind, Vec2, + pos2, vec2, }; fn contrast_color(color: impl Into) -> Color32 { diff --git a/crates/egui/src/widgets/drag_value.rs b/crates/egui/src/widgets/drag_value.rs index a9d971916bf..9515726c211 100644 --- a/crates/egui/src/widgets/drag_value.rs +++ b/crates/egui/src/widgets/drag_value.rs @@ -3,8 +3,8 @@ use std::{cmp::Ordering, ops::RangeInclusive}; use crate::{ - emath, text, Button, CursorIcon, Id, Key, Modifiers, NumExt as _, Response, RichText, Sense, - TextEdit, TextWrapMode, Ui, Widget, WidgetInfo, MINUS_CHAR_STR, + Button, CursorIcon, Id, Key, MINUS_CHAR_STR, Modifiers, NumExt as _, Response, RichText, Sense, + TextEdit, TextWrapMode, Ui, Widget, WidgetInfo, emath, text, }; // ---------------------------------------------------------------------------- diff --git a/crates/egui/src/widgets/hyperlink.rs b/crates/egui/src/widgets/hyperlink.rs index 3e5ff88dccb..989643304aa 100644 --- a/crates/egui/src/widgets/hyperlink.rs +++ b/crates/egui/src/widgets/hyperlink.rs @@ -1,6 +1,6 @@ use crate::{ - epaint, text_selection, CursorIcon, Label, Response, Sense, Stroke, Ui, Widget, WidgetInfo, - WidgetText, WidgetType, + CursorIcon, Label, Response, Sense, Stroke, Ui, Widget, WidgetInfo, WidgetText, WidgetType, + epaint, text_selection, }; use self::text_selection::LabelSelectionState; diff --git a/crates/egui/src/widgets/image.rs b/crates/egui/src/widgets/image.rs index 07b08e53cb3..0ec4e9c90d3 100644 --- a/crates/egui/src/widgets/image.rs +++ b/crates/egui/src/widgets/image.rs @@ -2,14 +2,15 @@ use std::{borrow::Cow, slice::Iter, sync::Arc, time::Duration}; use emath::{Align, Float as _, GuiRounding as _, NumExt as _, Rot2}; use epaint::{ - text::{LayoutJob, TextFormat, TextWrapping}, RectShape, + text::{LayoutJob, TextFormat, TextWrapping}, }; use crate::{ - load::{Bytes, SizeHint, SizedTexture, TextureLoadResult, TexturePoll}, - pos2, Color32, Context, CornerRadius, Id, Mesh, Painter, Rect, Response, Sense, Shape, Spinner, + Color32, Context, CornerRadius, Id, Mesh, Painter, Rect, Response, Sense, Shape, Spinner, TextStyle, TextureOptions, Ui, Vec2, Widget, WidgetInfo, WidgetType, + load::{Bytes, SizeHint, SizedTexture, TextureLoadResult, TexturePoll}, + pos2, }; /// A widget which displays an image. @@ -499,7 +500,7 @@ impl ImageSize { let point_size = match fit { ImageFit::Original { scale } => { - return SizeHint::Scale((pixels_per_point * scale).ord()) + return SizeHint::Scale((pixels_per_point * scale).ord()); } ImageFit::Fraction(fract) => available_size * fract, ImageFit::Exact(size) => size, diff --git a/crates/egui/src/widgets/image_button.rs b/crates/egui/src/widgets/image_button.rs index 7962e5a4272..a765a745a07 100644 --- a/crates/egui/src/widgets/image_button.rs +++ b/crates/egui/src/widgets/image_button.rs @@ -1,6 +1,6 @@ use crate::{ - widgets, Color32, CornerRadius, Image, Rect, Response, Sense, Ui, Vec2, Widget, WidgetInfo, - WidgetType, + Color32, CornerRadius, Image, Rect, Response, Sense, Ui, Vec2, Widget, WidgetInfo, WidgetType, + widgets, }; /// A clickable image within a frame. diff --git a/crates/egui/src/widgets/label.rs b/crates/egui/src/widgets/label.rs index 9f3606d12cc..aa229adff8a 100644 --- a/crates/egui/src/widgets/label.rs +++ b/crates/egui/src/widgets/label.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use crate::{ - epaint, pos2, text_selection::LabelSelectionState, Align, Direction, FontSelection, Galley, - Pos2, Response, Sense, Stroke, TextWrapMode, Ui, Widget, WidgetInfo, WidgetText, WidgetType, + Align, Direction, FontSelection, Galley, Pos2, Response, Sense, Stroke, TextWrapMode, Ui, + Widget, WidgetInfo, WidgetText, WidgetType, epaint, pos2, text_selection::LabelSelectionState, }; /// Static text. diff --git a/crates/egui/src/widgets/mod.rs b/crates/egui/src/widgets/mod.rs index a4a40ec66f1..d303b181b36 100644 --- a/crates/egui/src/widgets/mod.rs +++ b/crates/egui/src/widgets/mod.rs @@ -4,7 +4,7 @@ //! * `ui.add(Label::new("Text").text_color(color::red));` //! * `if ui.add(Button::new("Click me")).clicked() { … }` -use crate::{epaint, Response, Ui}; +use crate::{Response, Ui, epaint}; mod button; mod checkbox; @@ -28,8 +28,8 @@ pub use self::{ drag_value::DragValue, hyperlink::{Hyperlink, Link}, image::{ - decode_animated_image_uri, has_gif_magic_header, has_webp_header, paint_texture_at, FrameDurations, Image, ImageFit, ImageOptions, ImageSize, ImageSource, + decode_animated_image_uri, has_gif_magic_header, has_webp_header, paint_texture_at, }, image_button::ImageButton, label::Label, diff --git a/crates/egui/src/widgets/progress_bar.rs b/crates/egui/src/widgets/progress_bar.rs index 6739c0e2ece..bba6be8ef65 100644 --- a/crates/egui/src/widgets/progress_bar.rs +++ b/crates/egui/src/widgets/progress_bar.rs @@ -1,6 +1,6 @@ use crate::{ - lerp, vec2, Color32, CornerRadius, NumExt as _, Pos2, Rect, Response, Rgba, Sense, Shape, - Stroke, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, + Color32, CornerRadius, NumExt as _, Pos2, Rect, Response, Rgba, Sense, Shape, Stroke, + TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetType, lerp, vec2, }; enum ProgressBarText { diff --git a/crates/egui/src/widgets/radio_button.rs b/crates/egui/src/widgets/radio_button.rs index 53dda399f4b..8b1f7cc4b52 100644 --- a/crates/egui/src/widgets/radio_button.rs +++ b/crates/egui/src/widgets/radio_button.rs @@ -1,6 +1,6 @@ use crate::{ - epaint, Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Ui, Vec2, Widget, - WidgetInfo, WidgetType, + Atom, AtomLayout, Atoms, Id, IntoAtoms, NumExt as _, Response, Sense, Ui, Vec2, Widget, + WidgetInfo, WidgetType, epaint, }; /// One out of several alternatives, either selected or not. diff --git a/crates/egui/src/widgets/separator.rs b/crates/egui/src/widgets/separator.rs index d018cfa4d0d..6fdd03b96b1 100644 --- a/crates/egui/src/widgets/separator.rs +++ b/crates/egui/src/widgets/separator.rs @@ -1,4 +1,4 @@ -use crate::{vec2, Response, Sense, Ui, Vec2, Widget}; +use crate::{Response, Sense, Ui, Vec2, Widget, vec2}; /// A visual separator. A horizontal or vertical line (depending on [`crate::Layout`]). /// diff --git a/crates/egui/src/widgets/slider.rs b/crates/egui/src/widgets/slider.rs index 8ad88349170..777c2eed121 100644 --- a/crates/egui/src/widgets/slider.rs +++ b/crates/egui/src/widgets/slider.rs @@ -3,9 +3,9 @@ use std::ops::RangeInclusive; use crate::{ - emath, epaint, lerp, pos2, remap, remap_clamp, style, style::HandleShape, vec2, Color32, - DragValue, EventFilter, Key, Label, NumExt as _, Pos2, Rangef, Rect, Response, Sense, - TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, MINUS_CHAR_STR, + Color32, DragValue, EventFilter, Key, Label, MINUS_CHAR_STR, NumExt as _, Pos2, Rangef, Rect, + Response, Sense, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, emath, + epaint, lerp, pos2, remap, remap_clamp, style, style::HandleShape, vec2, }; use super::drag_value::clamp_value_to_range; @@ -134,11 +134,7 @@ impl<'a> Slider<'a> { value.to_f64() }); - if Num::INTEGRAL { - slf.integer() - } else { - slf - } + if Num::INTEGRAL { slf.integer() } else { slf } } pub fn from_get_set( diff --git a/crates/egui/src/widgets/spinner.rs b/crates/egui/src/widgets/spinner.rs index abb4b27bc12..573517dcb93 100644 --- a/crates/egui/src/widgets/spinner.rs +++ b/crates/egui/src/widgets/spinner.rs @@ -1,4 +1,4 @@ -use epaint::{emath::lerp, vec2, Color32, Pos2, Rect, Shape, Stroke}; +use epaint::{Color32, Pos2, Rect, Shape, Stroke, emath::lerp, vec2}; use crate::{Response, Sense, Ui, Widget, WidgetInfo, WidgetType}; diff --git a/crates/egui/src/widgets/text_edit/builder.rs b/crates/egui/src/widgets/text_edit/builder.rs index e21c512a926..d5a00656466 100644 --- a/crates/egui/src/widgets/text_edit/builder.rs +++ b/crates/egui/src/widgets/text_edit/builder.rs @@ -2,19 +2,19 @@ use std::sync::Arc; use emath::{Rect, TSTransform}; use epaint::{ - text::{cursor::CCursor, Galley, LayoutJob}, StrokeKind, + text::{Galley, LayoutJob, cursor::CCursor}, }; use crate::{ - epaint, + Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, ImeEvent, + Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape, TextBuffer, + TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, epaint, os::OperatingSystem, output::OutputEvent, response, text_selection, - text_selection::{text_cursor_state::cursor_rect, visuals::paint_text_selection, CCursorRange}, - vec2, Align, Align2, Color32, Context, CursorIcon, Event, EventFilter, FontSelection, Id, - ImeEvent, Key, KeyboardShortcut, Margin, Modifiers, NumExt as _, Response, Sense, Shape, - TextBuffer, TextStyle, TextWrapMode, Ui, Vec2, Widget, WidgetInfo, WidgetText, WidgetWithState, + text_selection::{CCursorRange, text_cursor_state::cursor_rect, visuals::paint_text_selection}, + vec2, }; use super::{TextEditOutput, TextEditState}; diff --git a/crates/egui/src/widgets/text_edit/state.rs b/crates/egui/src/widgets/text_edit/state.rs index 0051ea8e7ef..11304e700bd 100644 --- a/crates/egui/src/widgets/text_edit/state.rs +++ b/crates/egui/src/widgets/text_edit/state.rs @@ -3,8 +3,8 @@ use std::sync::Arc; use crate::mutex::Mutex; use crate::{ - text_selection::{CCursorRange, TextCursorState}, Context, Id, + text_selection::{CCursorRange, TextCursorState}, }; pub type TextEditUndoer = crate::util::undoer::Undoer<(CCursorRange, String)>; diff --git a/crates/egui/src/widgets/text_edit/text_buffer.rs b/crates/egui/src/widgets/text_edit/text_buffer.rs index ebf33b097dc..a67dc1b3851 100644 --- a/crates/egui/src/widgets/text_edit/text_buffer.rs +++ b/crates/egui/src/widgets/text_edit/text_buffer.rs @@ -1,8 +1,8 @@ use std::{borrow::Cow, ops::Range}; use epaint::{ - text::{cursor::CCursor, TAB_SIZE}, Galley, + text::{TAB_SIZE, cursor::CCursor}, }; use crate::{ diff --git a/crates/egui_demo_app/src/apps/fractal_clock.rs b/crates/egui_demo_app/src/apps/fractal_clock.rs index 3eeddd7beed..50d9ae5efed 100644 --- a/crates/egui_demo_app/src/apps/fractal_clock.rs +++ b/crates/egui_demo_app/src/apps/fractal_clock.rs @@ -1,8 +1,8 @@ use egui::{ + Color32, Painter, Pos2, Rect, Shape, Stroke, Ui, Vec2, containers::{CollapsingHeader, Frame}, emath, pos2, widgets::Slider, - Color32, Painter, Pos2, Rect, Shape, Stroke, Ui, Vec2, }; use std::f32::consts::TAU; diff --git a/crates/egui_demo_app/src/apps/image_viewer.rs b/crates/egui_demo_app/src/apps/image_viewer.rs index 326718a235e..75ff2719018 100644 --- a/crates/egui_demo_app/src/apps/image_viewer.rs +++ b/crates/egui_demo_app/src/apps/image_viewer.rs @@ -1,9 +1,9 @@ -use egui::emath::Rot2; -use egui::panel::Side; -use egui::panel::TopBottomSide; use egui::ImageFit; use egui::Slider; use egui::Vec2; +use egui::emath::Rot2; +use egui::panel::Side; +use egui::panel::TopBottomSide; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub struct ImageViewer { diff --git a/crates/egui_demo_app/src/frame_history.rs b/crates/egui_demo_app/src/frame_history.rs index 231ba4a4f44..0b34f858a18 100644 --- a/crates/egui_demo_app/src/frame_history.rs +++ b/crates/egui_demo_app/src/frame_history.rs @@ -53,7 +53,7 @@ impl FrameHistory { } fn graph(&self, ui: &mut egui::Ui) -> egui::Response { - use egui::{emath, epaint, pos2, vec2, Pos2, Rect, Sense, Shape, Stroke, TextStyle}; + use egui::{Pos2, Rect, Sense, Shape, Stroke, TextStyle, emath, epaint, pos2, vec2}; ui.label("egui CPU usage history"); diff --git a/crates/egui_demo_app/src/main.rs b/crates/egui_demo_app/src/main.rs index cf391ee9937..638b60f2a50 100644 --- a/crates/egui_demo_app/src/main.rs +++ b/crates/egui_demo_app/src/main.rs @@ -16,7 +16,9 @@ fn main() -> eframe::Result { start_puffin_server(); #[cfg(not(feature = "puffin"))] - panic!("Unknown argument: {arg} - you need to enable the 'puffin' feature to use this."); + panic!( + "Unknown argument: {arg} - you need to enable the 'puffin' feature to use this." + ); } _ => { diff --git a/crates/egui_demo_app/tests/test_demo_app.rs b/crates/egui_demo_app/tests/test_demo_app.rs index 65afff10f1a..961990b9012 100644 --- a/crates/egui_demo_app/tests/test_demo_app.rs +++ b/crates/egui_demo_app/tests/test_demo_app.rs @@ -1,8 +1,8 @@ -use egui::accesskit::Role; use egui::Vec2; +use egui::accesskit::Role; use egui_demo_app::{Anchor, WrapApp}; -use egui_kittest::kittest::Queryable as _; use egui_kittest::SnapshotResults; +use egui_kittest::kittest::Queryable as _; #[test] fn test_demo_app() { diff --git a/crates/egui_demo_lib/benches/benchmark.rs b/crates/egui_demo_lib/benches/benchmark.rs index b511f0de8dc..e0c86f0dba5 100644 --- a/crates/egui_demo_lib/benches/benchmark.rs +++ b/crates/egui_demo_lib/benches/benchmark.rs @@ -1,6 +1,6 @@ use std::fmt::Write as _; -use criterion::{criterion_group, criterion_main, BatchSize, Criterion}; +use criterion::{BatchSize, Criterion, criterion_group, criterion_main}; use egui::epaint::TextShape; use egui::load::SizedTexture; @@ -174,7 +174,7 @@ pub fn criterion_benchmark(c: &mut Criterion) { let mut locked_fonts = fonts.lock(); c.bench_function("text_layout_uncached", |b| { b.iter(|| { - use egui::epaint::text::{layout, LayoutJob}; + use egui::epaint::text::{LayoutJob, layout}; let job = LayoutJob::simple( LOREM_IPSUM_LONG.to_owned(), diff --git a/crates/egui_demo_lib/src/demo/dancing_strings.rs b/crates/egui_demo_lib/src/demo/dancing_strings.rs index dd480181dc2..cc4b578c0ef 100644 --- a/crates/egui_demo_lib/src/demo/dancing_strings.rs +++ b/crates/egui_demo_lib/src/demo/dancing_strings.rs @@ -1,8 +1,9 @@ use egui::{ + Color32, Context, Pos2, Rect, Ui, containers::{Frame, Window}, emath, epaint, epaint::PathStroke, - hex_color, lerp, pos2, remap, vec2, Color32, Context, Pos2, Rect, Ui, + hex_color, lerp, pos2, remap, vec2, }; #[derive(Default)] diff --git a/crates/egui_demo_lib/src/demo/demo_app_windows.rs b/crates/egui_demo_lib/src/demo/demo_app_windows.rs index 6e9a92ef4bb..0e3a0d2c2c6 100644 --- a/crates/egui_demo_lib/src/demo/demo_app_windows.rs +++ b/crates/egui_demo_lib/src/demo/demo_app_windows.rs @@ -1,9 +1,9 @@ use std::collections::BTreeSet; use super::About; -use crate::is_mobile; use crate::Demo; use crate::View as _; +use crate::is_mobile; use egui::containers::menu; use egui::style::StyleModifier; use egui::{Context, Modifiers, ScrollArea, Ui}; @@ -370,7 +370,7 @@ fn file_menu_button(ui: &mut Ui) { #[cfg(test)] mod tests { - use crate::{demo::demo_app_windows::DemoGroups, Demo as _}; + use crate::{Demo as _, demo::demo_app_windows::DemoGroups}; use egui_kittest::kittest::{NodeT as _, Queryable as _}; use egui_kittest::{Harness, SnapshotOptions, SnapshotResults}; diff --git a/crates/egui_demo_lib/src/demo/drag_and_drop.rs b/crates/egui_demo_lib/src/demo/drag_and_drop.rs index 7fa3f01bb50..d483ced3f85 100644 --- a/crates/egui_demo_lib/src/demo/drag_and_drop.rs +++ b/crates/egui_demo_lib/src/demo/drag_and_drop.rs @@ -1,4 +1,4 @@ -use egui::{vec2, Color32, Context, Frame, Id, Ui, Window}; +use egui::{Color32, Context, Frame, Id, Ui, Window, vec2}; #[derive(Clone, PartialEq, Eq)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/demo/misc_demo_window.rs b/crates/egui_demo_lib/src/demo/misc_demo_window.rs index 99d85aeebf7..5af27d5e4b5 100644 --- a/crates/egui_demo_lib/src/demo/misc_demo_window.rs +++ b/crates/egui_demo_lib/src/demo/misc_demo_window.rs @@ -1,8 +1,8 @@ use super::{Demo, View}; use egui::{ - vec2, Align, Align2, Checkbox, CollapsingHeader, Color32, ComboBox, Context, FontId, Resize, - RichText, Sense, Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window, + Align, Align2, Checkbox, CollapsingHeader, Color32, ComboBox, Context, FontId, Resize, + RichText, Sense, Slider, Stroke, TextFormat, TextStyle, Ui, Vec2, Window, vec2, }; /// Showcase some ui code diff --git a/crates/egui_demo_lib/src/demo/modals.rs b/crates/egui_demo_lib/src/demo/modals.rs index 5fb1548e3bd..0aefbce82aa 100644 --- a/crates/egui_demo_lib/src/demo/modals.rs +++ b/crates/egui_demo_lib/src/demo/modals.rs @@ -162,10 +162,10 @@ impl crate::View for Modals { #[cfg(test)] mod tests { - use crate::demo::modals::Modals; use crate::Demo as _; - use egui::accesskit::Role; + use crate::demo::modals::Modals; use egui::Key; + use egui::accesskit::Role; use egui_kittest::kittest::Queryable as _; use egui_kittest::{Harness, SnapshotResults}; diff --git a/crates/egui_demo_lib/src/demo/multi_touch.rs b/crates/egui_demo_lib/src/demo/multi_touch.rs index b6580c5f879..0c2d9820238 100644 --- a/crates/egui_demo_lib/src/demo/multi_touch.rs +++ b/crates/egui_demo_lib/src/demo/multi_touch.rs @@ -1,6 +1,7 @@ use egui::{ + Color32, Frame, Pos2, Rect, Sense, Stroke, Vec2, emath::{RectTransform, Rot2}, - vec2, Color32, Frame, Pos2, Rect, Sense, Stroke, Vec2, + vec2, }; pub struct MultiTouch { diff --git a/crates/egui_demo_lib/src/demo/paint_bezier.rs b/crates/egui_demo_lib/src/demo/paint_bezier.rs index df85e4377c5..7017560a52c 100644 --- a/crates/egui_demo_lib/src/demo/paint_bezier.rs +++ b/crates/egui_demo_lib/src/demo/paint_bezier.rs @@ -1,8 +1,8 @@ use egui::{ - emath, + Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2, + Widget as _, Window, emath, epaint::{self, CubicBezierShape, PathShape, QuadraticBezierShape}, - pos2, Color32, Context, Frame, Grid, Pos2, Rect, Sense, Shape, Stroke, StrokeKind, Ui, Vec2, - Widget as _, Window, + pos2, }; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/demo/painting.rs b/crates/egui_demo_lib/src/demo/painting.rs index 8e1df7ae7a2..5a4942f6873 100644 --- a/crates/egui_demo_lib/src/demo/painting.rs +++ b/crates/egui_demo_lib/src/demo/painting.rs @@ -1,4 +1,4 @@ -use egui::{emath, vec2, Color32, Context, Frame, Pos2, Rect, Sense, Stroke, Ui, Window}; +use egui::{Color32, Context, Frame, Pos2, Rect, Sense, Stroke, Ui, Window, emath, vec2}; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(default))] diff --git a/crates/egui_demo_lib/src/demo/popups.rs b/crates/egui_demo_lib/src/demo/popups.rs index f9815a6bffa..6f7152c2b59 100644 --- a/crates/egui_demo_lib/src/demo/popups.rs +++ b/crates/egui_demo_lib/src/demo/popups.rs @@ -1,9 +1,9 @@ use crate::rust_view_ui; -use egui::color_picker::{color_picker_color32, Alpha}; +use egui::color_picker::{Alpha, color_picker_color32}; use egui::containers::menu::{MenuConfig, SubMenuButton}; use egui::{ - include_image, Align, Align2, ComboBox, Frame, Id, Layout, Popup, PopupCloseBehavior, - RectAlign, RichText, Tooltip, Ui, UiBuilder, + Align, Align2, ComboBox, Frame, Id, Layout, Popup, PopupCloseBehavior, RectAlign, RichText, + Tooltip, Ui, UiBuilder, include_image, }; /// Showcase [`Popup`]. diff --git a/crates/egui_demo_lib/src/demo/scrolling.rs b/crates/egui_demo_lib/src/demo/scrolling.rs index dab3c4f5a4e..3e4660d3d45 100644 --- a/crates/egui_demo_lib/src/demo/scrolling.rs +++ b/crates/egui_demo_lib/src/demo/scrolling.rs @@ -1,6 +1,6 @@ use egui::{ - pos2, scroll_area::ScrollBarVisibility, Align, Align2, Color32, DragValue, NumExt as _, Rect, - ScrollArea, Sense, Slider, TextStyle, TextWrapMode, Ui, Vec2, Widget as _, + Align, Align2, Color32, DragValue, NumExt as _, Rect, ScrollArea, Sense, Slider, TextStyle, + TextWrapMode, Ui, Vec2, Widget as _, pos2, scroll_area::ScrollBarVisibility, }; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/demo/sliders.rs b/crates/egui_demo_lib/src/demo/sliders.rs index ef8bdb0cd11..6b512e1eac4 100644 --- a/crates/egui_demo_lib/src/demo/sliders.rs +++ b/crates/egui_demo_lib/src/demo/sliders.rs @@ -1,4 +1,4 @@ -use egui::{style::HandleShape, Slider, SliderClamping, SliderOrientation, Ui}; +use egui::{Slider, SliderClamping, SliderOrientation, Ui, style::HandleShape}; /// Showcase sliders #[derive(PartialEq)] diff --git a/crates/egui_demo_lib/src/demo/table_demo.rs b/crates/egui_demo_lib/src/demo/table_demo.rs index 17e19d01d8f..5a55569b744 100644 --- a/crates/egui_demo_lib/src/demo/table_demo.rs +++ b/crates/egui_demo_lib/src/demo/table_demo.rs @@ -330,7 +330,9 @@ fn expanding_content(ui: &mut egui::Ui) { } fn long_text(row_index: usize) -> String { - format!("Row {row_index} has some long text that you may want to clip, or it will take up too much horizontal space!") + format!( + "Row {row_index} has some long text that you may want to clip, or it will take up too much horizontal space!" + ) } fn thick_row(row_index: usize) -> bool { diff --git a/crates/egui_demo_lib/src/demo/tests/layout_test.rs b/crates/egui_demo_lib/src/demo/tests/layout_test.rs index f58369121b8..f63eff0a9a1 100644 --- a/crates/egui_demo_lib/src/demo/tests/layout_test.rs +++ b/crates/egui_demo_lib/src/demo/tests/layout_test.rs @@ -1,4 +1,4 @@ -use egui::{vec2, Align, Direction, Layout, Resize, Slider, Ui}; +use egui::{Align, Direction, Layout, Resize, Slider, Ui, vec2}; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] #[cfg_attr(feature = "serde", serde(default))] diff --git a/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs b/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs index 20e8d21bf49..c1a325a5f13 100644 --- a/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs +++ b/crates/egui_demo_lib/src/demo/tests/tessellation_test.rs @@ -1,7 +1,8 @@ use egui::{ + Color32, Pos2, Rect, Sense, StrokeKind, Vec2, emath::{GuiRounding as _, TSTransform}, epaint::{self, RectShape}, - vec2, Color32, Pos2, Rect, Sense, StrokeKind, Vec2, + vec2, }; #[derive(Clone, Debug, PartialEq)] diff --git a/crates/egui_demo_lib/src/demo/text_edit.rs b/crates/egui_demo_lib/src/demo/text_edit.rs index 4ef34a51eec..a36ad6837e3 100644 --- a/crates/egui_demo_lib/src/demo/text_edit.rs +++ b/crates/egui_demo_lib/src/demo/text_edit.rs @@ -113,9 +113,9 @@ impl crate::View for TextEditDemo { #[cfg(test)] mod tests { - use egui::{accesskit, CentralPanel, Key, Modifiers}; - use egui_kittest::kittest::Queryable as _; + use egui::{CentralPanel, Key, Modifiers, accesskit}; use egui_kittest::Harness; + use egui_kittest::kittest::Queryable as _; #[test] pub fn should_type() { diff --git a/crates/egui_demo_lib/src/demo/undo_redo.rs b/crates/egui_demo_lib/src/demo/undo_redo.rs index 525e26c6f59..04610031c5b 100644 --- a/crates/egui_demo_lib/src/demo/undo_redo.rs +++ b/crates/egui_demo_lib/src/demo/undo_redo.rs @@ -1,4 +1,4 @@ -use egui::{util::undoer::Undoer, Button}; +use egui::{Button, util::undoer::Undoer}; #[derive(Debug, PartialEq, Eq, Clone)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs index 292e5f0aa62..d17385a6815 100644 --- a/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs +++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_editor.rs @@ -1,5 +1,5 @@ use egui::{ - text::CCursorRange, Key, KeyboardShortcut, Modifiers, ScrollArea, TextBuffer, TextEdit, Ui, + Key, KeyboardShortcut, Modifiers, ScrollArea, TextBuffer, TextEdit, Ui, text::CCursorRange, }; #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] diff --git a/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs b/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs index 17d3858f7a7..13ff7da0316 100644 --- a/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs +++ b/crates/egui_demo_lib/src/easy_mark/easy_mark_viewer.rs @@ -1,7 +1,7 @@ use super::easy_mark_parser as easy_mark; use egui::{ - vec2, Align, Align2, Hyperlink, Layout, Response, RichText, Sense, Separator, Shape, TextStyle, - Ui, + Align, Align2, Hyperlink, Layout, Response, RichText, Sense, Separator, Shape, TextStyle, Ui, + vec2, }; /// Parse and display a VERY simple and small subset of Markdown. diff --git a/crates/egui_demo_lib/src/rendering_test.rs b/crates/egui_demo_lib/src/rendering_test.rs index 32e51a82a44..e14bfca0766 100644 --- a/crates/egui_demo_lib/src/rendering_test.rs +++ b/crates/egui_demo_lib/src/rendering_test.rs @@ -1,9 +1,9 @@ use std::collections::HashMap; use egui::{ - emath::GuiRounding as _, epaint, lerp, pos2, vec2, widgets::color_picker::show_color, Align2, - Color32, FontId, Image, Mesh, Pos2, Rect, Response, Rgba, RichText, Sense, Shape, Stroke, - TextureHandle, TextureOptions, Ui, Vec2, + Align2, Color32, FontId, Image, Mesh, Pos2, Rect, Response, Rgba, RichText, Sense, Shape, + Stroke, TextureHandle, TextureOptions, Ui, Vec2, emath::GuiRounding as _, epaint, lerp, pos2, + vec2, widgets::color_picker::show_color, }; const GRADIENT_SIZE: Vec2 = vec2(256.0, 18.0); @@ -722,8 +722,8 @@ fn mul_color_gamma(left: Color32, right: Color32) -> Color32 { #[cfg(test)] mod tests { use crate::ColorTest; - use egui_kittest::kittest::Queryable as _; use egui_kittest::SnapshotResults; + use egui_kittest::kittest::Queryable as _; #[test] pub fn rendering_test() { diff --git a/crates/egui_extras/src/layout.rs b/crates/egui_extras/src/layout.rs index b1c79d0a650..d9210187b79 100644 --- a/crates/egui_extras/src/layout.rs +++ b/crates/egui_extras/src/layout.rs @@ -1,4 +1,4 @@ -use egui::{emath::GuiRounding as _, Id, Pos2, Rect, Response, Sense, Ui, UiBuilder}; +use egui::{Id, Pos2, Rect, Response, Sense, Ui, UiBuilder, emath::GuiRounding as _}; #[derive(Clone, Copy)] pub(crate) enum CellSize { diff --git a/crates/egui_extras/src/loaders/ehttp_loader.rs b/crates/egui_extras/src/loaders/ehttp_loader.rs index 22785eedbab..abe5d96f14e 100644 --- a/crates/egui_extras/src/loaders/ehttp_loader.rs +++ b/crates/egui_extras/src/loaders/ehttp_loader.rs @@ -19,13 +19,13 @@ impl File { return Err(format!( "failed to load {uri:?}: {} {} {response_text}", response.status, response.status_text - )) + )); } None => { return Err(format!( "failed to load {uri:?}: {} {}", response.status, response.status_text - )) + )); } } } diff --git a/crates/egui_extras/src/loaders/gif_loader.rs b/crates/egui_extras/src/loaders/gif_loader.rs index a92cbc33e41..9f0786cfb60 100644 --- a/crates/egui_extras/src/loaders/gif_loader.rs +++ b/crates/egui_extras/src/loaders/gif_loader.rs @@ -1,9 +1,8 @@ use ahash::HashMap; use egui::{ - decode_animated_image_uri, has_gif_magic_header, + ColorImage, FrameDurations, Id, decode_animated_image_uri, has_gif_magic_header, load::{BytesPoll, ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint}, mutex::Mutex, - ColorImage, FrameDurations, Id, }; use image::AnimationDecoder as _; use std::{io::Cursor, mem::size_of, sync::Arc, time::Duration}; diff --git a/crates/egui_extras/src/loaders/image_loader.rs b/crates/egui_extras/src/loaders/image_loader.rs index 7f472dcc4c4..18e1e483b97 100644 --- a/crates/egui_extras/src/loaders/image_loader.rs +++ b/crates/egui_extras/src/loaders/image_loader.rs @@ -1,9 +1,8 @@ use ahash::HashMap; use egui::{ - decode_animated_image_uri, + ColorImage, decode_animated_image_uri, load::{Bytes, BytesPoll, ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint}, mutex::Mutex, - ColorImage, }; use image::ImageFormat; use std::{mem::size_of, path::Path, sync::Arc, task::Poll}; diff --git a/crates/egui_extras/src/loaders/svg_loader.rs b/crates/egui_extras/src/loaders/svg_loader.rs index fab70151f55..4b778ff9ee1 100644 --- a/crates/egui_extras/src/loaders/svg_loader.rs +++ b/crates/egui_extras/src/loaders/svg_loader.rs @@ -1,17 +1,17 @@ use std::{ mem::size_of, sync::{ - atomic::{AtomicU64, Ordering::Relaxed}, Arc, + atomic::{AtomicU64, Ordering::Relaxed}, }, }; use ahash::HashMap; use egui::{ + ColorImage, load::{BytesPoll, ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint}, mutex::Mutex, - ColorImage, }; struct Entry { diff --git a/crates/egui_extras/src/loaders/webp_loader.rs b/crates/egui_extras/src/loaders/webp_loader.rs index ef1a5d5274b..f0dc32ae4fd 100644 --- a/crates/egui_extras/src/loaders/webp_loader.rs +++ b/crates/egui_extras/src/loaders/webp_loader.rs @@ -1,11 +1,10 @@ use ahash::HashMap; use egui::{ - decode_animated_image_uri, has_webp_header, + ColorImage, FrameDurations, Id, decode_animated_image_uri, has_webp_header, load::{BytesPoll, ImageLoadResult, ImageLoader, ImagePoll, LoadError, SizeHint}, mutex::Mutex, - ColorImage, FrameDurations, Id, }; -use image::{codecs::webp::WebPDecoder, AnimationDecoder as _, ColorType, ImageDecoder as _, Rgba}; +use image::{AnimationDecoder as _, ColorType, ImageDecoder as _, Rgba, codecs::webp::WebPDecoder}; use std::{io::Cursor, mem::size_of, sync::Arc, time::Duration}; #[derive(Clone)] @@ -55,7 +54,7 @@ impl WebP { unreachable => { return Err(format!( "Unreachable WebP color type, expected Rgb8/Rgba8, got {unreachable:?}" - )) + )); } }; diff --git a/crates/egui_extras/src/strip.rs b/crates/egui_extras/src/strip.rs index 00fc6577423..da64b4f9e9a 100644 --- a/crates/egui_extras/src/strip.rs +++ b/crates/egui_extras/src/strip.rs @@ -1,7 +1,7 @@ use crate::{ + Size, layout::{CellDirection, CellSize, StripLayout, StripLayoutFlags}, sizing::Sizing, - Size, }; use egui::{Response, Ui}; diff --git a/crates/egui_extras/src/syntax_highlighting.rs b/crates/egui_extras/src/syntax_highlighting.rs index 2476e783b92..894f2cc249d 100644 --- a/crates/egui_extras/src/syntax_highlighting.rs +++ b/crates/egui_extras/src/syntax_highlighting.rs @@ -5,8 +5,8 @@ #![allow(clippy::mem_forget)] // False positive from enum_map macro -use egui::text::LayoutJob; use egui::TextStyle; +use egui::text::LayoutJob; /// View some code with syntax highlighting and selection. pub fn code_view_ui( diff --git a/crates/egui_extras/src/table.rs b/crates/egui_extras/src/table.rs index 2d64f25709c..9d77c60c82d 100644 --- a/crates/egui_extras/src/table.rs +++ b/crates/egui_extras/src/table.rs @@ -4,13 +4,13 @@ //! Takes all available height, so if you want something below the table, put it in a strip. use egui::{ - scroll_area::{ScrollAreaOutput, ScrollBarVisibility, ScrollSource}, Align, Id, NumExt as _, Rangef, Rect, Response, ScrollArea, Ui, Vec2, Vec2b, + scroll_area::{ScrollAreaOutput, ScrollBarVisibility, ScrollSource}, }; use crate::{ - layout::{CellDirection, CellSize, StripLayoutFlags}, StripLayout, + layout::{CellDirection, CellSize, StripLayoutFlags}, }; // -----------------------------------------------------------------=---------- diff --git a/crates/egui_glow/src/lib.rs b/crates/egui_glow/src/lib.rs index aaea1d0b9b3..174f022269c 100644 --- a/crates/egui_glow/src/lib.rs +++ b/crates/egui_glow/src/lib.rs @@ -62,12 +62,8 @@ macro_rules! check_for_gl_error { /// ``` #[macro_export] macro_rules! check_for_gl_error_even_in_release { - ($gl: expr) => {{ - $crate::check_for_gl_error_impl($gl, file!(), line!(), "") - }}; - ($gl: expr, $context: literal) => {{ - $crate::check_for_gl_error_impl($gl, file!(), line!(), $context) - }}; + ($gl: expr) => {{ $crate::check_for_gl_error_impl($gl, file!(), line!(), "") }}; + ($gl: expr, $context: literal) => {{ $crate::check_for_gl_error_impl($gl, file!(), line!(), $context) }}; } #[doc(hidden)] diff --git a/crates/egui_glow/src/painter.rs b/crates/egui_glow/src/painter.rs index 0646b560daa..a5e7b3c1f46 100644 --- a/crates/egui_glow/src/painter.rs +++ b/crates/egui_glow/src/painter.rs @@ -445,7 +445,9 @@ impl Painter { if let Some(callback) = callback.callback.downcast_ref::() { (callback.f)(info, self); } else { - log::warn!("Warning: Unsupported render callback. Expected egui_glow::CallbackFn"); + log::warn!( + "Warning: Unsupported render callback. Expected egui_glow::CallbackFn" + ); } check_for_gl_error!(&self.gl, "callback"); diff --git a/crates/egui_glow/src/shader_version.rs b/crates/egui_glow/src/shader_version.rs index 249cda36986..b655c567cb6 100644 --- a/crates/egui_glow/src/shader_version.rs +++ b/crates/egui_glow/src/shader_version.rs @@ -47,11 +47,7 @@ impl ShaderVersion { .try_into() .unwrap(); if es { - if maj >= 3 { - Self::Es300 - } else { - Self::Es100 - } + if maj >= 3 { Self::Es300 } else { Self::Es100 } } else if maj > 1 || (maj == 1 && min >= 40) { Self::Gl140 } else { diff --git a/crates/egui_glow/src/winit.rs b/crates/egui_glow/src/winit.rs index c4569015a09..2fe15dcd070 100644 --- a/crates/egui_glow/src/winit.rs +++ b/crates/egui_glow/src/winit.rs @@ -1,8 +1,8 @@ use ahash::HashSet; use egui::{ViewportId, ViewportOutput}; pub use egui_winit; -use egui_winit::winit; pub use egui_winit::EventResponse; +use egui_winit::winit; use crate::shader_version::ShaderVersion; diff --git a/crates/egui_kittest/src/node.rs b/crates/egui_kittest/src/node.rs index 384a5dbd44a..51a0cc3a04f 100644 --- a/crates/egui_kittest/src/node.rs +++ b/crates/egui_kittest/src/node.rs @@ -1,7 +1,7 @@ use egui::accesskit::ActionRequest; use egui::mutex::Mutex; -use egui::{accesskit, Modifiers, PointerButton, Pos2}; -use kittest::{debug_fmt_node, AccessKitNode, NodeT}; +use egui::{Modifiers, PointerButton, Pos2, accesskit}; +use kittest::{AccessKitNode, NodeT, debug_fmt_node}; use std::fmt::{Debug, Formatter}; pub(crate) enum EventType { diff --git a/crates/egui_kittest/src/snapshot.rs b/crates/egui_kittest/src/snapshot.rs index c85a09070b6..3c7dc265ad8 100644 --- a/crates/egui_kittest/src/snapshot.rs +++ b/crates/egui_kittest/src/snapshot.rs @@ -128,11 +128,17 @@ impl Display for SnapshotError { write!(f, "Missing snapshot: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}") } err => { - write!(f, "Error reading snapshot: {err:?}\nAt: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}") + write!( + f, + "Error reading snapshot: {err:?}\nAt: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}" + ) } }, err => { - write!(f, "Error decoding snapshot: {err:?}\nAt: {path:?}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/main/CONTRIBUTING.md#making-a-pr") + write!( + f, + "Error decoding snapshot: {err:?}\nAt: {path:?}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/main/CONTRIBUTING.md#making-a-pr" + ) } } } @@ -555,11 +561,7 @@ impl SnapshotResults { /// Convert this into a `Result<(), Self>`. #[expect(clippy::missing_errors_doc)] pub fn into_result(self) -> Result<(), Self> { - if self.has_errors() { - Err(self) - } else { - Ok(()) - } + if self.has_errors() { Err(self) } else { Ok(()) } } pub fn into_inner(mut self) -> Vec { diff --git a/crates/egui_kittest/src/wgpu.rs b/crates/egui_kittest/src/wgpu.rs index efd954245fb..e0fef29013f 100644 --- a/crates/egui_kittest/src/wgpu.rs +++ b/crates/egui_kittest/src/wgpu.rs @@ -2,7 +2,7 @@ use std::iter::once; use std::sync::Arc; use egui::TexturesDelta; -use egui_wgpu::{wgpu, RenderState, ScreenDescriptor, WgpuSetup}; +use egui_wgpu::{RenderState, ScreenDescriptor, WgpuSetup, wgpu}; use image::RgbaImage; use crate::texture_to_image::texture_to_image; diff --git a/crates/egui_kittest/tests/accesskit.rs b/crates/egui_kittest/tests/accesskit.rs index 02afddefc80..3f1f33ba9e1 100644 --- a/crates/egui_kittest/tests/accesskit.rs +++ b/crates/egui_kittest/tests/accesskit.rs @@ -1,8 +1,8 @@ //! Tests the accesskit accessibility output of egui. use egui::{ - accesskit::{NodeId, Role, TreeUpdate}, CentralPanel, Context, RawInput, Window, + accesskit::{NodeId, Role, TreeUpdate}, }; /// Baseline test that asserts there are no spurious nodes in the diff --git a/crates/egui_kittest/tests/menu.rs b/crates/egui_kittest/tests/menu.rs index 48f348a21b9..00470bd5ca2 100644 --- a/crates/egui_kittest/tests/menu.rs +++ b/crates/egui_kittest/tests/menu.rs @@ -1,5 +1,5 @@ use egui::containers::menu::{Bar, MenuConfig, SubMenuButton}; -use egui::{include_image, PopupCloseBehavior, Ui}; +use egui::{PopupCloseBehavior, Ui, include_image}; use egui_kittest::{Harness, SnapshotResults}; use kittest::Queryable as _; diff --git a/crates/egui_kittest/tests/regression_tests.rs b/crates/egui_kittest/tests/regression_tests.rs index 5c7b4fc53e8..0cae152bf58 100644 --- a/crates/egui_kittest/tests/regression_tests.rs +++ b/crates/egui_kittest/tests/regression_tests.rs @@ -2,7 +2,7 @@ use egui::accesskit::{self, Role}; use egui::{Button, ComboBox, Image, Vec2, Widget as _}; #[cfg(all(feature = "wgpu", feature = "snapshot"))] use egui_kittest::SnapshotResults; -use egui_kittest::{kittest::Queryable as _, Harness}; +use egui_kittest::{Harness, kittest::Queryable as _}; #[test] pub fn focus_should_skip_over_disabled_buttons() { diff --git a/crates/egui_kittest/tests/tests.rs b/crates/egui_kittest/tests/tests.rs index 8c92f4314f1..b4e49642f79 100644 --- a/crates/egui_kittest/tests/tests.rs +++ b/crates/egui_kittest/tests/tests.rs @@ -1,4 +1,4 @@ -use egui::{include_image, Modifiers, Vec2}; +use egui::{Modifiers, Vec2, include_image}; use egui_kittest::Harness; use kittest::Queryable as _; diff --git a/crates/emath/src/align.rs b/crates/emath/src/align.rs index b1b56755ec4..89b28d4af92 100644 --- a/crates/emath/src/align.rs +++ b/crates/emath/src/align.rs @@ -1,6 +1,6 @@ //! One- and two-dimensional alignment ([`Align::Center`], [`Align2::LEFT_TOP`] etc). -use crate::{pos2, vec2, Pos2, Rangef, Rect, Vec2}; +use crate::{Pos2, Rangef, Rect, Vec2, pos2, vec2}; /// left/center/right or top/center/bottom alignment for e.g. anchors and layouts. #[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] diff --git a/crates/emath/src/easing.rs b/crates/emath/src/easing.rs index 352c451c214..95fc7250d51 100644 --- a/crates/emath/src/easing.rs +++ b/crates/emath/src/easing.rs @@ -137,11 +137,7 @@ pub fn exponential_in(t: f32) -> f32 { /// There is a small discontinuity at 1. #[inline] pub fn exponential_out(t: f32) -> f32 { - if t == 1. { - t - } else { - 1. - powf(2.0, -10. * t) - } + if t == 1. { t } else { 1. - powf(2.0, -10. * t) } } /// diff --git a/crates/emath/src/lib.rs b/crates/emath/src/lib.rs index 337fa204549..2d9dfb2f13c 100644 --- a/crates/emath/src/lib.rs +++ b/crates/emath/src/lib.rs @@ -44,7 +44,7 @@ mod vec2b; pub use self::{ align::{Align, Align2}, - gui_rounding::{GuiRounding, GUI_ROUNDING}, + gui_rounding::{GUI_ROUNDING, GuiRounding}, history::History, numeric::*, ordered_float::*, @@ -182,11 +182,7 @@ where ); let t = (x - *from.start()) / (*from.end() - *from.start()); // Ensure no numerical inaccuracies sneak in: - if T::ONE <= t { - *to.end() - } else { - lerp(to, t) - } + if T::ONE <= t { *to.end() } else { lerp(to, t) } } } diff --git a/crates/emath/src/pos2.rs b/crates/emath/src/pos2.rs index 62590b10f45..fc26686b32a 100644 --- a/crates/emath/src/pos2.rs +++ b/crates/emath/src/pos2.rs @@ -3,7 +3,7 @@ use std::{ ops::{Add, AddAssign, MulAssign, Sub, SubAssign}, }; -use crate::{lerp, Div, Mul, Vec2}; +use crate::{Div, Mul, Vec2, lerp}; /// A position on screen. /// diff --git a/crates/emath/src/rect.rs b/crates/emath/src/rect.rs index 00bed04f0f8..dc63315b6e1 100644 --- a/crates/emath/src/rect.rs +++ b/crates/emath/src/rect.rs @@ -1,6 +1,6 @@ use std::fmt; -use crate::{lerp, pos2, vec2, Div, Mul, Pos2, Rangef, Rot2, Vec2}; +use crate::{Div, Mul, Pos2, Rangef, Rot2, Vec2, lerp, pos2, vec2}; /// A rectangular region of space. /// diff --git a/crates/emath/src/rect_transform.rs b/crates/emath/src/rect_transform.rs index da9382790da..3539efe755f 100644 --- a/crates/emath/src/rect_transform.rs +++ b/crates/emath/src/rect_transform.rs @@ -1,4 +1,4 @@ -use crate::{pos2, remap, remap_clamp, Pos2, Rect, Vec2}; +use crate::{Pos2, Rect, Vec2, pos2, remap, remap_clamp}; /// Linearly transforms positions from one [`Rect`] to another. /// diff --git a/crates/emath/src/vec2.rs b/crates/emath/src/vec2.rs index 4771343e8e2..f79359df9a4 100644 --- a/crates/emath/src/vec2.rs +++ b/crates/emath/src/vec2.rs @@ -170,11 +170,7 @@ impl Vec2 { #[inline(always)] pub fn normalized(self) -> Self { let len = self.length(); - if len <= 0.0 { - self - } else { - self / len - } + if len <= 0.0 { self } else { self / len } } /// Checks if `self` has length `1.0` up to a precision of `1e-6`. diff --git a/crates/epaint/benches/benchmark.rs b/crates/epaint/benches/benchmark.rs index 14f4d2fa767..676e1d0fd33 100644 --- a/crates/epaint/benches/benchmark.rs +++ b/crates/epaint/benches/benchmark.rs @@ -1,8 +1,8 @@ -use criterion::{black_box, criterion_group, criterion_main, Criterion}; +use criterion::{Criterion, black_box, criterion_group, criterion_main}; use epaint::{ - pos2, tessellator::Path, ClippedShape, Color32, Mesh, PathStroke, Pos2, Rect, Shape, Stroke, - TessellationOptions, Tessellator, TextureAtlas, Vec2, + ClippedShape, Color32, Mesh, PathStroke, Pos2, Rect, Shape, Stroke, TessellationOptions, + Tessellator, TextureAtlas, Vec2, pos2, tessellator::Path, }; #[global_allocator] diff --git a/crates/epaint/src/image.rs b/crates/epaint/src/image.rs index b6183e7a1cc..8fcef2df7eb 100644 --- a/crates/epaint/src/image.rs +++ b/crates/epaint/src/image.rs @@ -1,6 +1,6 @@ use emath::Vec2; -use crate::{textures::TextureOptions, Color32}; +use crate::{Color32, textures::TextureOptions}; use std::sync::Arc; /// An image stored in RAM. diff --git a/crates/epaint/src/lib.rs b/crates/epaint/src/lib.rs index 633aa668977..264966809be 100644 --- a/crates/epaint/src/lib.rs +++ b/crates/epaint/src/lib.rs @@ -73,7 +73,7 @@ pub use self::{ pub type Rounding = CornerRadius; pub use ecolor::{Color32, Hsva, HsvaGamma, Rgba}; -pub use emath::{pos2, vec2, Pos2, Rect, Vec2}; +pub use emath::{Pos2, Rect, Vec2, pos2, vec2}; #[deprecated = "Use the ahash crate directly."] pub use ahash; diff --git a/crates/epaint/src/margin.rs b/crates/epaint/src/margin.rs index 417cc55685a..e6f6d228796 100644 --- a/crates/epaint/src/margin.rs +++ b/crates/epaint/src/margin.rs @@ -1,4 +1,4 @@ -use emath::{vec2, Rect, Vec2}; +use emath::{Rect, Vec2, vec2}; /// A value for all four sides of a rectangle, /// often used to express padding or spacing. diff --git a/crates/epaint/src/margin_f32.rs b/crates/epaint/src/margin_f32.rs index fd88611d04e..22bc8b3d43a 100644 --- a/crates/epaint/src/margin_f32.rs +++ b/crates/epaint/src/margin_f32.rs @@ -1,4 +1,4 @@ -use emath::{vec2, Rect, Vec2}; +use emath::{Rect, Vec2, vec2}; use crate::Margin; diff --git a/crates/epaint/src/mesh.rs b/crates/epaint/src/mesh.rs index 60be2935c52..fbff16ba2cd 100644 --- a/crates/epaint/src/mesh.rs +++ b/crates/epaint/src/mesh.rs @@ -1,4 +1,4 @@ -use crate::{emath, Color32, TextureId, WHITE_UV}; +use crate::{Color32, TextureId, WHITE_UV, emath}; use emath::{Pos2, Rect, Rot2, TSTransform, Vec2}; /// The 2D vertex type. diff --git a/crates/epaint/src/shadow.rs b/crates/epaint/src/shadow.rs index ee010ee99dd..ace5ab90a52 100644 --- a/crates/epaint/src/shadow.rs +++ b/crates/epaint/src/shadow.rs @@ -29,7 +29,8 @@ pub struct Shadow { #[test] fn shadow_size() { assert_eq!( - std::mem::size_of::(), 8, + std::mem::size_of::(), + 8, "Shadow changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it." ); } diff --git a/crates/epaint/src/shape_transform.rs b/crates/epaint/src/shape_transform.rs index 57de149692d..4b68d5964c1 100644 --- a/crates/epaint/src/shape_transform.rs +++ b/crates/epaint/src/shape_transform.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use crate::{ - color, CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh, PathShape, - QuadraticBezierShape, RectShape, Shape, TextShape, + CircleShape, Color32, ColorMode, CubicBezierShape, EllipseShape, Mesh, PathShape, + QuadraticBezierShape, RectShape, Shape, TextShape, color, }; /// Remember to handle [`Color32::PLACEHOLDER`] specially! diff --git a/crates/epaint/src/shapes/rect_shape.rs b/crates/epaint/src/shapes/rect_shape.rs index ead5b7af268..2e855d36905 100644 --- a/crates/epaint/src/shapes/rect_shape.rs +++ b/crates/epaint/src/shapes/rect_shape.rs @@ -59,7 +59,8 @@ pub struct RectShape { #[test] fn rect_shape_size() { assert_eq!( - std::mem::size_of::(), 48, + std::mem::size_of::(), + 48, "RectShape changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it." ); assert!( diff --git a/crates/epaint/src/shapes/shape.rs b/crates/epaint/src/shapes/shape.rs index bc16e43d552..080f1794b2d 100644 --- a/crates/epaint/src/shapes/shape.rs +++ b/crates/epaint/src/shapes/shape.rs @@ -2,12 +2,12 @@ use std::sync::Arc; -use emath::{pos2, Align2, Pos2, Rangef, Rect, TSTransform, Vec2}; +use emath::{Align2, Pos2, Rangef, Rect, TSTransform, Vec2, pos2}; use crate::{ + Color32, CornerRadius, Mesh, Stroke, StrokeKind, TextureId, stroke::PathStroke, text::{FontId, Fonts, Galley}, - Color32, CornerRadius, Mesh, Stroke, StrokeKind, TextureId, }; use super::{ @@ -73,7 +73,8 @@ pub enum Shape { #[test] fn shape_size() { assert_eq!( - std::mem::size_of::(), 64, + std::mem::size_of::(), + 64, "Shape changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it." ); assert!( diff --git a/crates/epaint/src/stroke.rs b/crates/epaint/src/stroke.rs index 50f4f678b96..473376f4078 100644 --- a/crates/epaint/src/stroke.rs +++ b/crates/epaint/src/stroke.rs @@ -4,7 +4,7 @@ use std::{fmt::Debug, sync::Arc}; use emath::GuiRounding as _; -use super::{emath, Color32, ColorMode, Pos2, Rect}; +use super::{Color32, ColorMode, Pos2, Rect, emath}; /// Describes the width and color of a line. /// diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index b083ea452c1..4b1b23ba0c5 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -5,13 +5,13 @@ #![allow(clippy::identity_op)] -use emath::{pos2, remap, vec2, GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2}; +use emath::{GuiRounding as _, NumExt as _, Pos2, Rect, Rot2, Vec2, pos2, remap, vec2}; use crate::{ - color::ColorMode, emath, stroke::PathStroke, texture_atlas::PreparedDisc, CircleShape, - ClippedPrimitive, ClippedShape, Color32, CornerRadiusF32, CubicBezierShape, EllipseShape, Mesh, - PathShape, Primitive, QuadraticBezierShape, RectShape, Shape, Stroke, StrokeKind, TextShape, - TextureId, Vertex, WHITE_UV, + CircleShape, ClippedPrimitive, ClippedShape, Color32, CornerRadiusF32, CubicBezierShape, + EllipseShape, Mesh, PathShape, Primitive, QuadraticBezierShape, RectShape, Shape, Stroke, + StrokeKind, TextShape, TextureId, Vertex, WHITE_UV, color::ColorMode, emath, + stroke::PathStroke, texture_atlas::PreparedDisc, }; // ---------------------------------------------------------------------------- @@ -28,7 +28,7 @@ mod precomputed_vertices { // println!("];") // } - use emath::{vec2, Vec2}; + use emath::{Vec2, vec2}; pub const CIRCLE_8: [Vec2; 9] = [ vec2(1.000000, 0.000000), @@ -340,7 +340,7 @@ impl Path { } pub fn add_circle(&mut self, center: Pos2, radius: f32) { - use precomputed_vertices::{CIRCLE_128, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_8}; + use precomputed_vertices::{CIRCLE_8, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_128}; // These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here? // same cutoffs as in add_circle_quadrant @@ -535,7 +535,7 @@ impl Path { pub mod path { //! Helpers for constructing paths use crate::CornerRadiusF32; - use emath::{pos2, Pos2, Rect}; + use emath::{Pos2, Rect, pos2}; /// overwrites existing points pub fn rounded_rectangle(path: &mut Vec, rect: Rect, cr: CornerRadiusF32) { @@ -602,7 +602,7 @@ pub mod path { // - quadrant 3: right top // * angle 4 * TAU / 4 = right pub fn add_circle_quadrant(path: &mut Vec, center: Pos2, radius: f32, quadrant: f32) { - use super::precomputed_vertices::{CIRCLE_128, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_8}; + use super::precomputed_vertices::{CIRCLE_8, CIRCLE_16, CIRCLE_32, CIRCLE_64, CIRCLE_128}; // These cutoffs are based on a high-dpi display. TODO(emilk): use pixels_per_point here? // same cutoffs as in add_circle diff --git a/crates/epaint/src/text/font.rs b/crates/epaint/src/text/font.rs index b79bea2f249..72fffaad01a 100644 --- a/crates/epaint/src/text/font.rs +++ b/crates/epaint/src/text/font.rs @@ -1,12 +1,12 @@ use std::collections::BTreeMap; use std::sync::Arc; -use emath::{vec2, GuiRounding as _, Vec2}; +use emath::{GuiRounding as _, Vec2, vec2}; use crate::{ + TextureAtlas, mutex::{Mutex, RwLock}, text::FontTweak, - TextureAtlas, }; // ---------------------------------------------------------------------------- diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index e655142151f..574e83cfcd8 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -1,12 +1,12 @@ use std::{collections::BTreeMap, sync::Arc}; use crate::{ + TextureAtlas, mutex::{Mutex, MutexGuard}, text::{ - font::{Font, FontImpl}, Galley, LayoutJob, LayoutSection, + font::{Font, FontImpl}, }, - TextureAtlas, }; use emath::{NumExt as _, OrderedFloat}; @@ -1050,7 +1050,7 @@ mod tests { use core::f32; use super::*; - use crate::{text::TextFormat, Stroke}; + use crate::{Stroke, text::TextFormat}; use ecolor::Color32; use emath::Align; diff --git a/crates/epaint/src/text/text_layout.rs b/crates/epaint/src/text/text_layout.rs index 63dfc389311..3777d860c56 100644 --- a/crates/epaint/src/text/text_layout.rs +++ b/crates/epaint/src/text/text_layout.rs @@ -1,8 +1,8 @@ use std::sync::Arc; -use emath::{pos2, vec2, Align, GuiRounding as _, NumExt as _, Pos2, Rect, Vec2}; +use emath::{Align, GuiRounding as _, NumExt as _, Pos2, Rect, Vec2, pos2, vec2}; -use crate::{stroke::PathStroke, text::font::Font, Color32, Mesh, Stroke, Vertex}; +use crate::{Color32, Mesh, Stroke, Vertex, stroke::PathStroke, text::font::Font}; use super::{FontsImpl, Galley, Glyph, LayoutJob, LayoutSection, PlacedRow, Row, RowVisuals}; diff --git a/crates/epaint/src/text/text_layout_types.rs b/crates/epaint/src/text/text_layout_types.rs index f7e11911b73..016bfe10447 100644 --- a/crates/epaint/src/text/text_layout_types.rs +++ b/crates/epaint/src/text/text_layout_types.rs @@ -9,7 +9,7 @@ use super::{ font::UvRect, }; use crate::{Color32, FontId, Mesh, Stroke}; -use emath::{pos2, vec2, Align, GuiRounding as _, NumExt as _, OrderedFloat, Pos2, Rect, Vec2}; +use emath::{Align, GuiRounding as _, NumExt as _, OrderedFloat, Pos2, Rect, Vec2, pos2, vec2}; /// Describes the task of laying out text. /// diff --git a/crates/epaint/src/texture_atlas.rs b/crates/epaint/src/texture_atlas.rs index 79054022439..8e174e544c5 100644 --- a/crates/epaint/src/texture_atlas.rs +++ b/crates/epaint/src/texture_atlas.rs @@ -1,4 +1,4 @@ -use emath::{remap_clamp, Rect}; +use emath::{Rect, remap_clamp}; use crate::{FontImage, ImageDelta}; diff --git a/crates/epaint/src/texture_handle.rs b/crates/epaint/src/texture_handle.rs index 315437750f0..919b7405fc7 100644 --- a/crates/epaint/src/texture_handle.rs +++ b/crates/epaint/src/texture_handle.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use crate::{ - emath::NumExt as _, mutex::RwLock, textures::TextureOptions, ImageData, ImageDelta, TextureId, - TextureManager, + ImageData, ImageDelta, TextureId, TextureManager, emath::NumExt as _, mutex::RwLock, + textures::TextureOptions, }; /// Used to paint images. diff --git a/examples/confirm_exit/Cargo.toml b/examples/confirm_exit/Cargo.toml index 2e5e1c085db..d7de7866caf 100644 --- a/examples/confirm_exit/Cargo.toml +++ b/examples/confirm_exit/Cargo.toml @@ -3,7 +3,7 @@ name = "confirm_exit" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_3d_glow/Cargo.toml b/examples/custom_3d_glow/Cargo.toml index fa11a8b5e7b..1d78565ec41 100644 --- a/examples/custom_3d_glow/Cargo.toml +++ b/examples/custom_3d_glow/Cargo.toml @@ -3,7 +3,7 @@ name = "custom_3d_glow" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_font/Cargo.toml b/examples/custom_font/Cargo.toml index dc42990bbb7..86ce17bfb6a 100644 --- a/examples/custom_font/Cargo.toml +++ b/examples/custom_font/Cargo.toml @@ -3,7 +3,7 @@ name = "custom_font" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_font_style/Cargo.toml b/examples/custom_font_style/Cargo.toml index ff9bde8ce65..b3cd82d2adc 100644 --- a/examples/custom_font_style/Cargo.toml +++ b/examples/custom_font_style/Cargo.toml @@ -3,7 +3,7 @@ name = "custom_font_style" version = "0.1.0" authors = ["tami5 "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_keypad/Cargo.toml b/examples/custom_keypad/Cargo.toml index 1b4c5ca4e64..de66772da18 100644 --- a/examples/custom_keypad/Cargo.toml +++ b/examples/custom_keypad/Cargo.toml @@ -3,7 +3,7 @@ name = "custom_keypad" version = "0.1.0" authors = ["Varphone Wong "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_keypad/src/keypad.rs b/examples/custom_keypad/src/keypad.rs index 1934ff60271..ddc67546145 100644 --- a/examples/custom_keypad/src/keypad.rs +++ b/examples/custom_keypad/src/keypad.rs @@ -1,4 +1,4 @@ -use eframe::egui::{self, pos2, vec2, Button, Ui, Vec2}; +use eframe::egui::{self, Button, Ui, Vec2, pos2, vec2}; #[derive(Clone, Copy, Debug, Default, PartialEq)] enum Transition { diff --git a/examples/custom_style/Cargo.toml b/examples/custom_style/Cargo.toml index 59630678234..baae7bfc134 100644 --- a/examples/custom_style/Cargo.toml +++ b/examples/custom_style/Cargo.toml @@ -2,7 +2,7 @@ name = "custom_style" version = "0.1.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_style/src/main.rs b/examples/custom_style/src/main.rs index 1e78bea0fdf..58f7e1d3a58 100644 --- a/examples/custom_style/src/main.rs +++ b/examples/custom_style/src/main.rs @@ -2,7 +2,7 @@ #![allow(rustdoc::missing_crate_level_docs)] // it's an example use eframe::egui::{ - self, global_theme_preference_buttons, style::Selection, Color32, Stroke, Style, Theme, + self, Color32, Stroke, Style, Theme, global_theme_preference_buttons, style::Selection, }; use egui_demo_lib::{View as _, WidgetGallery}; diff --git a/examples/custom_window_frame/Cargo.toml b/examples/custom_window_frame/Cargo.toml index 21c8e8ef0e7..74f07237e39 100644 --- a/examples/custom_window_frame/Cargo.toml +++ b/examples/custom_window_frame/Cargo.toml @@ -3,7 +3,7 @@ name = "custom_window_frame" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/custom_window_frame/src/main.rs b/examples/custom_window_frame/src/main.rs index bf347848f23..bc7ddcb8235 100644 --- a/examples/custom_window_frame/src/main.rs +++ b/examples/custom_window_frame/src/main.rs @@ -75,7 +75,7 @@ fn custom_window_frame(ctx: &egui::Context, title: &str, add_contents: impl FnOn } fn title_bar_ui(ui: &mut egui::Ui, title_bar_rect: eframe::epaint::Rect, title: &str) { - use egui::{vec2, Align2, FontId, Id, PointerButton, Sense, UiBuilder}; + use egui::{Align2, FontId, Id, PointerButton, Sense, UiBuilder, vec2}; let painter = ui.painter(); diff --git a/examples/external_eventloop/Cargo.toml b/examples/external_eventloop/Cargo.toml index 884791f3ab8..e14852930c3 100644 --- a/examples/external_eventloop/Cargo.toml +++ b/examples/external_eventloop/Cargo.toml @@ -3,7 +3,7 @@ name = "external_eventloop" version = "0.1.0" authors = ["Will Brown "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/external_eventloop/src/main.rs b/examples/external_eventloop/src/main.rs index 178c2865fa6..d72f6914a0a 100644 --- a/examples/external_eventloop/src/main.rs +++ b/examples/external_eventloop/src/main.rs @@ -1,7 +1,7 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![allow(rustdoc::missing_crate_level_docs)] // it's an example -use eframe::{egui, UserEvent}; +use eframe::{UserEvent, egui}; use std::{cell::Cell, rc::Rc}; use winit::event_loop::{ControlFlow, EventLoop}; diff --git a/examples/external_eventloop_async/Cargo.toml b/examples/external_eventloop_async/Cargo.toml index e7a0913bc4e..5305bdbb3c5 100644 --- a/examples/external_eventloop_async/Cargo.toml +++ b/examples/external_eventloop_async/Cargo.toml @@ -3,7 +3,7 @@ name = "external_eventloop_async" version = "0.1.0" authors = ["Will Brown "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/external_eventloop_async/src/app.rs b/examples/external_eventloop_async/src/app.rs index de3326b19c3..a7b3e0efe8c 100644 --- a/examples/external_eventloop_async/src/app.rs +++ b/examples/external_eventloop_async/src/app.rs @@ -1,4 +1,4 @@ -use eframe::{egui, EframePumpStatus, UserEvent}; +use eframe::{EframePumpStatus, UserEvent, egui}; use std::{cell::Cell, io, os::fd::AsRawFd as _, rc::Rc, time::Duration}; use tokio::task::LocalSet; use winit::event_loop::{ControlFlow, EventLoop}; diff --git a/examples/file_dialog/Cargo.toml b/examples/file_dialog/Cargo.toml index 290ea3c668c..bf437a396e7 100644 --- a/examples/file_dialog/Cargo.toml +++ b/examples/file_dialog/Cargo.toml @@ -3,7 +3,7 @@ name = "file_dialog" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/hello_android/Cargo.toml b/examples/hello_android/Cargo.toml index b8b76362275..6e077c74f55 100644 --- a/examples/hello_android/Cargo.toml +++ b/examples/hello_android/Cargo.toml @@ -3,7 +3,7 @@ name = "hello_android" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/hello_android/src/lib.rs b/examples/hello_android/src/lib.rs index c91c0e75403..c138b97e13e 100644 --- a/examples/hello_android/src/lib.rs +++ b/examples/hello_android/src/lib.rs @@ -1,6 +1,6 @@ #![doc = include_str!("../README.md")] -use eframe::{egui, CreationContext}; +use eframe::{CreationContext, egui}; #[cfg(target_os = "android")] #[no_mangle] diff --git a/examples/hello_world/Cargo.toml b/examples/hello_world/Cargo.toml index 37803d3aafc..4a5779b8c10 100644 --- a/examples/hello_world/Cargo.toml +++ b/examples/hello_world/Cargo.toml @@ -3,7 +3,7 @@ name = "hello_world" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/hello_world_par/Cargo.toml b/examples/hello_world_par/Cargo.toml index 38c0d2b53b4..ee3cb7c8425 100644 --- a/examples/hello_world_par/Cargo.toml +++ b/examples/hello_world_par/Cargo.toml @@ -3,7 +3,7 @@ name = "hello_world_par" version = "0.1.0" authors = ["Maxim Osipenko "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/hello_world_simple/Cargo.toml b/examples/hello_world_simple/Cargo.toml index 1c4e30b9856..d5ce9162513 100644 --- a/examples/hello_world_simple/Cargo.toml +++ b/examples/hello_world_simple/Cargo.toml @@ -3,7 +3,7 @@ name = "hello_world_simple" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/images/Cargo.toml b/examples/images/Cargo.toml index c3317b38b60..01b63625c24 100644 --- a/examples/images/Cargo.toml +++ b/examples/images/Cargo.toml @@ -3,7 +3,7 @@ name = "images" version = "0.1.0" authors = ["Jan Procházka "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/keyboard_events/Cargo.toml b/examples/keyboard_events/Cargo.toml index 9ca900a28f2..2ae7b073190 100644 --- a/examples/keyboard_events/Cargo.toml +++ b/examples/keyboard_events/Cargo.toml @@ -3,7 +3,7 @@ name = "keyboard_events" version = "0.1.0" authors = ["Jose Palazon "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/multiple_viewports/Cargo.toml b/examples/multiple_viewports/Cargo.toml index 84aca3c8562..a672ea0db2a 100644 --- a/examples/multiple_viewports/Cargo.toml +++ b/examples/multiple_viewports/Cargo.toml @@ -3,7 +3,7 @@ name = "multiple_viewports" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/multiple_viewports/src/main.rs b/examples/multiple_viewports/src/main.rs index a8adab2c788..919c24a3ae8 100644 --- a/examples/multiple_viewports/src/main.rs +++ b/examples/multiple_viewports/src/main.rs @@ -2,8 +2,8 @@ #![allow(rustdoc::missing_crate_level_docs)] // it's an example use std::sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }; use eframe::egui; diff --git a/examples/puffin_profiler/Cargo.toml b/examples/puffin_profiler/Cargo.toml index 041b13de1cb..536f6ae728a 100644 --- a/examples/puffin_profiler/Cargo.toml +++ b/examples/puffin_profiler/Cargo.toml @@ -3,7 +3,7 @@ name = "puffin_profiler" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index b75a20e0054..ababe336aaf 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -2,8 +2,8 @@ #![allow(rustdoc::missing_crate_level_docs)] // it's an example use std::sync::{ - atomic::{AtomicBool, Ordering}, Arc, + atomic::{AtomicBool, Ordering}, }; use eframe::egui; diff --git a/examples/screenshot/Cargo.toml b/examples/screenshot/Cargo.toml index 2e775eb7d4f..d633159cc0c 100644 --- a/examples/screenshot/Cargo.toml +++ b/examples/screenshot/Cargo.toml @@ -6,7 +6,7 @@ authors = [ "Andreas Faber "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/user_attention/Cargo.toml b/examples/user_attention/Cargo.toml index 7d5ce61a9ed..24d362e8c24 100644 --- a/examples/user_attention/Cargo.toml +++ b/examples/user_attention/Cargo.toml @@ -3,7 +3,7 @@ name = "user_attention" version = "0.1.0" authors = ["TicClick "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/examples/user_attention/src/main.rs b/examples/user_attention/src/main.rs index 3d171c279e8..6851b736e92 100644 --- a/examples/user_attention/src/main.rs +++ b/examples/user_attention/src/main.rs @@ -1,7 +1,7 @@ #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release #![allow(rustdoc::missing_crate_level_docs)] // it's an example -use eframe::{egui, CreationContext, NativeOptions}; +use eframe::{CreationContext, NativeOptions, egui}; use egui::{Button, CentralPanel, Context, UserAttentionType}; use std::time::{Duration, SystemTime}; diff --git a/tests/egui_tests/tests/regression_tests.rs b/tests/egui_tests/tests/regression_tests.rs index d677594274e..9a33c9359de 100644 --- a/tests/egui_tests/tests/regression_tests.rs +++ b/tests/egui_tests/tests/regression_tests.rs @@ -1,6 +1,6 @@ -use egui::{include_image, Image}; -use egui_kittest::kittest::Queryable as _; +use egui::{Image, include_image}; use egui_kittest::Harness; +use egui_kittest::kittest::Queryable as _; #[test] fn image_button_should_have_alt_text() { diff --git a/tests/egui_tests/tests/test_widgets.rs b/tests/egui_tests/tests/test_widgets.rs index e7082d472b5..4ec31752185 100644 --- a/tests/egui_tests/tests/test_widgets.rs +++ b/tests/egui_tests/tests/test_widgets.rs @@ -1,10 +1,10 @@ use egui::load::SizedTexture; use egui::{ - include_image, Align, AtomExt as _, AtomLayout, Button, Color32, ColorImage, Direction, - DragValue, Event, Grid, IntoAtoms as _, Layout, PointerButton, Response, Slider, Stroke, - StrokeKind, TextWrapMode, TextureHandle, TextureOptions, Ui, UiBuilder, Vec2, Widget as _, + Align, AtomExt as _, AtomLayout, Button, Color32, ColorImage, Direction, DragValue, Event, + Grid, IntoAtoms as _, Layout, PointerButton, Response, Slider, Stroke, StrokeKind, + TextWrapMode, TextureHandle, TextureOptions, Ui, UiBuilder, Vec2, Widget as _, include_image, }; -use egui_kittest::kittest::{by, Queryable as _}; +use egui_kittest::kittest::{Queryable as _, by}; use egui_kittest::{Harness, Node, SnapshotResult, SnapshotResults}; #[test] diff --git a/tests/test_egui_extras_compilation/Cargo.toml b/tests/test_egui_extras_compilation/Cargo.toml index 102130cf83a..6058a186523 100644 --- a/tests/test_egui_extras_compilation/Cargo.toml +++ b/tests/test_egui_extras_compilation/Cargo.toml @@ -2,7 +2,7 @@ name = "test_egui_extras_compilation" version = "0.1.0" license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/tests/test_inline_glow_paint/Cargo.toml b/tests/test_inline_glow_paint/Cargo.toml index d26cb864cf1..5171700ea0a 100644 --- a/tests/test_inline_glow_paint/Cargo.toml +++ b/tests/test_inline_glow_paint/Cargo.toml @@ -3,7 +3,7 @@ name = "test_inline_glow_paint" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/tests/test_size_pass/Cargo.toml b/tests/test_size_pass/Cargo.toml index 760571a2dc6..6dbdfe1c05e 100644 --- a/tests/test_size_pass/Cargo.toml +++ b/tests/test_size_pass/Cargo.toml @@ -3,7 +3,7 @@ name = "test_size_pass" version = "0.1.0" authors = ["Emil Ernerfeldt "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/tests/test_ui_stack/Cargo.toml b/tests/test_ui_stack/Cargo.toml index 43fd45420b4..a826324a097 100644 --- a/tests/test_ui_stack/Cargo.toml +++ b/tests/test_ui_stack/Cargo.toml @@ -3,7 +3,7 @@ name = "test_ui_stack" version = "0.1.0" authors = ["Antoine Beyeler "] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/tests/test_viewports/Cargo.toml b/tests/test_viewports/Cargo.toml index 33b7829b31a..9a64b485db6 100644 --- a/tests/test_viewports/Cargo.toml +++ b/tests/test_viewports/Cargo.toml @@ -3,7 +3,7 @@ name = "test_viewports" version = "0.1.0" authors = ["konkitoman"] license = "MIT OR Apache-2.0" -edition = "2021" +edition = "2024" rust-version = "1.85" publish = false diff --git a/tests/test_viewports/src/main.rs b/tests/test_viewports/src/main.rs index 3f9964c9445..9b787632336 100644 --- a/tests/test_viewports/src/main.rs +++ b/tests/test_viewports/src/main.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use eframe::egui; -use egui::{mutex::RwLock, Id, InnerResponse, UiBuilder, ViewportBuilder, ViewportId}; +use egui::{Id, InnerResponse, UiBuilder, ViewportBuilder, ViewportId, mutex::RwLock}; // Drag-and-drop between windows is not yet implemented, but if you wanna work on it, enable this: pub const DRAG_AND_DROP_TEST: bool = false; From f5221a15d70f92da8773c0cf9c6d3d1076f5f933 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 30 Jun 2025 13:46:31 +0200 Subject: [PATCH 2/4] Fix code --- crates/eframe/src/native/app_icon.rs | 2 +- crates/egui/src/input_state/touch_state.rs | 4 ++-- crates/egui_demo_app/src/main.rs | 7 ++++++- crates/epaint/src/text/fonts.rs | 3 ++- examples/puffin_profiler/src/main.rs | 8 +++++++- 5 files changed, 18 insertions(+), 6 deletions(-) diff --git a/crates/eframe/src/native/app_icon.rs b/crates/eframe/src/native/app_icon.rs index cbe31e2b356..b94d8f83b78 100644 --- a/crates/eframe/src/native/app_icon.rs +++ b/crates/eframe/src/native/app_icon.rs @@ -225,7 +225,7 @@ fn set_title_and_icon_mac(title: &str, icon_data: Option<&IconData>) -> AppIconS }; // TODO(madsmtm): Move this into `objc2-app-kit` - extern "C" { + unsafe extern "C" { static NSApp: Option<&'static NSApplication>; } diff --git a/crates/egui/src/input_state/touch_state.rs b/crates/egui/src/input_state/touch_state.rs index 2cb6d2ae094..102b91fff7a 100644 --- a/crates/egui/src/input_state/touch_state.rs +++ b/crates/egui/src/input_state/touch_state.rs @@ -174,7 +174,7 @@ impl TouchState { if added_or_removed_touches { // Adding or removing fingers makes the average values "jump". We better forget // about the previous values, and don't create delta information for this frame: - if let Some(ref mut state) = &mut self.gesture_state { + if let Some(state) = &mut self.gesture_state { state.previous = None; } } @@ -224,7 +224,7 @@ impl TouchState { fn update_gesture(&mut self, time: f64, pointer_pos: Option) { if let Some(dyn_state) = self.calc_dynamic_state() { - if let Some(ref mut state) = &mut self.gesture_state { + if let Some(state) = &mut self.gesture_state { // updating an ongoing gesture state.previous = Some(state.current); state.current = dyn_state; diff --git a/crates/egui_demo_app/src/main.rs b/crates/egui_demo_app/src/main.rs index 638b60f2a50..099d16f59ad 100644 --- a/crates/egui_demo_app/src/main.rs +++ b/crates/egui_demo_app/src/main.rs @@ -41,7 +41,12 @@ fn main() -> eframe::Result { rust_log += &format!(",{loud_crate}=warn"); } } - std::env::set_var("RUST_LOG", rust_log); + + // SAFETY: we call this from the main thread without any other threads running. + #[expect(unsafe_code)] + unsafe { + std::env::set_var("RUST_LOG", rust_log); + } } env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 574e83cfcd8..6e90b566690 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -680,7 +680,8 @@ impl FontsImpl { /// Get the right font implementation from size and [`FontFamily`]. pub fn font(&mut self, font_id: &FontId) -> &mut Font { - let FontId { mut size, family } = font_id; + let FontId { size, family } = font_id; + let mut size = *size; size = size.at_least(0.1).at_most(2048.0); self.sized_family diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index ababe336aaf..1386e488498 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -10,7 +10,13 @@ use eframe::egui; fn main() -> eframe::Result { let rust_log = std::env::var("RUST_LOG").unwrap_or_else(|_| "info".to_owned()); - std::env::set_var("RUST_LOG", rust_log); + + // SAFETY: we call this from the main thread without any other threads running. + #[expect(unsafe_code)] + unsafe { + std::env::set_var("RUST_LOG", rust_log); + }; + env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`). start_puffin_server(); // NOTE: you may only want to call this if the users specifies some flag or clicks a button! From 33df1292d8674d4c7fe928067bcf119fa564c5ed Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 30 Jun 2025 13:50:58 +0200 Subject: [PATCH 3/4] Disable if_let_mutex clippy lint --- Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 5b8b00278ab..b1f350b3df2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -171,7 +171,6 @@ fn_params_excessive_bools = "warn" fn_to_numeric_cast_any = "warn" from_iter_instead_of_collect = "warn" get_unwrap = "warn" -if_let_mutex = "warn" implicit_clone = "warn" implied_bounds_in_impls = "warn" imprecise_flops = "warn" From a5f247755a553af58b9107b948ee95bc57de8ebb Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 30 Jun 2025 13:52:54 +0200 Subject: [PATCH 4/4] Fix windows build --- crates/eframe/src/native/file_storage.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/eframe/src/native/file_storage.rs b/crates/eframe/src/native/file_storage.rs index d2d16281eab..82b666c29b6 100644 --- a/crates/eframe/src/native/file_storage.rs +++ b/crates/eframe/src/native/file_storage.rs @@ -55,7 +55,7 @@ fn roaming_appdata() -> Option { FOLDERID_RoamingAppData, KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath, }; - extern "C" { + unsafe extern "C" { fn wcslen(buf: *const u16) -> usize; } let mut path_raw = ptr::null_mut();