diff --git a/examples/control_flow.rs b/examples/control_flow.rs index ce4fc78f1..45148bfd2 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -44,7 +44,7 @@ fn main() { event_loop.run(move |event, _, control_flow| { use tao::event::StartCause; - println!("{:?}", event); + println!("{event:?}"); match event { Event::NewEvents(start_cause) => { wait_cancelled = match start_cause { @@ -69,19 +69,19 @@ fn main() { // See the `key_binding` example if Key::Character("1") == logical_key { mode = Mode::Wait; - println!("\nmode: {:?}\n", mode); + println!("\nmode: {mode:?}\n"); } if Key::Character("2") == logical_key { mode = Mode::WaitUntil; - println!("\nmode: {:?}\n", mode); + println!("\nmode: {mode:?}\n"); } if Key::Character("3") == logical_key { mode = Mode::Poll; - println!("\nmode: {:?}\n", mode); + println!("\nmode: {mode:?}\n"); } if Key::Character("r") == logical_key { request_redraw = !request_redraw; - println!("\nrequest_redraw: {}\n", request_redraw); + println!("\nrequest_redraw: {request_redraw}\n"); } if Key::Escape == logical_key { close_requested = true; diff --git a/examples/cursor_grab.rs b/examples/cursor_grab.rs index 27705528b..a939d8201 100644 --- a/examples/cursor_grab.rs +++ b/examples/cursor_grab.rs @@ -52,10 +52,10 @@ fn main() { _ => (), }, Event::DeviceEvent { event, .. } => match event { - DeviceEvent::MouseMotion { delta, .. } => println!("mouse moved: {:?}", delta), + DeviceEvent::MouseMotion { delta, .. } => println!("mouse moved: {delta:?}"), DeviceEvent::Button { button, state, .. } => match state { - ElementState::Pressed => println!("mouse button {} pressed", button), - ElementState::Released => println!("mouse button {} released", button), + ElementState::Pressed => println!("mouse button {button} pressed"), + ElementState::Released => println!("mouse button {button} released"), _ => (), }, _ => (), diff --git a/examples/custom_events.rs b/examples/custom_events.rs index fe2046c1d..f94d00113 100644 --- a/examples/custom_events.rs +++ b/examples/custom_events.rs @@ -40,7 +40,7 @@ fn main() { *control_flow = ControlFlow::Wait; match event { - Event::UserEvent(event) => println!("user event: {:?}", event), + Event::UserEvent(event) => println!("user event: {event:?}"), Event::WindowEvent { event: WindowEvent::CloseRequested, .. diff --git a/examples/decorations.rs b/examples/decorations.rs index ed5f61bdc..d9025e2b4 100644 --- a/examples/decorations.rs +++ b/examples/decorations.rs @@ -40,7 +40,7 @@ fn main() { .. } => { decorations = !decorations; - println!("Decorations: {}", decorations); + println!("Decorations: {decorations}"); window.set_decorations(decorations); } _ => (), diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index b89f5aaa4..c5d8bfacd 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -109,7 +109,7 @@ fn prompt_for_monitor(event_loop: &EventLoop<()>) -> MonitorHandle { fn prompt_for_video_mode(monitor: &MonitorHandle) -> VideoMode { for (i, video_mode) in monitor.video_modes().enumerate() { - println!("Video mode #{}: {}", i, video_mode); + println!("Video mode #{i}: {video_mode}"); } print!("Please write the number of the video mode to use: "); @@ -123,7 +123,7 @@ fn prompt_for_video_mode(monitor: &MonitorHandle) -> VideoMode { .nth(num) .expect("Please enter a valid ID"); - println!("Using {}", video_mode); + println!("Using {video_mode}"); video_mode } diff --git a/examples/mouse_wheel.rs b/examples/mouse_wheel.rs index f1595efba..8997a5e6f 100644 --- a/examples/mouse_wheel.rs +++ b/examples/mouse_wheel.rs @@ -30,7 +30,7 @@ fn main() { Event::DeviceEvent { event, .. } => match event { DeviceEvent::MouseWheel { delta, .. } => match delta { tao::event::MouseScrollDelta::LineDelta(x, y) => { - println!("mouse wheel Line Delta: ({},{})", x, y); + println!("mouse wheel Line Delta: ({x},{y})"); let pixels_per_line = 120.0; let mut pos = window.outer_position().unwrap(); pos.x -= (x * pixels_per_line) as i32; diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index f2633a57c..9882325d4 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -68,7 +68,7 @@ fn main() { .. } => { use Key::{ArrowLeft, ArrowRight, Character}; - window.set_title(&format!("{:?}", key)); + window.set_title(&format!("{key:?}")); let state = !modifiers.shift_key(); match &key { // WARNING: Consider using `key_without_modifers()` if available on your platform. diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index 300efa48a..32973057a 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -29,7 +29,7 @@ fn main() { { match event { WindowEvent::CloseRequested => { - println!("Window {:?} has received the signal to close", window_id); + println!("Window {window_id:?} has received the signal to close"); // This drops the window, causing it to close. windows.remove(&window_id); diff --git a/examples/parentwindow.rs b/examples/parentwindow.rs index 89fa43f63..238b80181 100644 --- a/examples/parentwindow.rs +++ b/examples/parentwindow.rs @@ -50,7 +50,7 @@ fn main() { Event::WindowEvent { event, window_id, .. } if event == WindowEvent::CloseRequested => { - println!("Window {:?} has received the signal to close", window_id); + println!("Window {window_id:?} has received the signal to close"); // This drop the window, causing it to close. windows.remove(&window_id); if windows.is_empty() { diff --git a/examples/request_redraw.rs b/examples/request_redraw.rs index 27a020078..f3f563c6f 100644 --- a/examples/request_redraw.rs +++ b/examples/request_redraw.rs @@ -19,7 +19,7 @@ fn main() { .unwrap(); event_loop.run(move |event, _, control_flow| { - println!("{:?}", event); + println!("{event:?}"); *control_flow = ControlFlow::Wait; diff --git a/examples/request_redraw_threaded.rs b/examples/request_redraw_threaded.rs index ea92a26fa..069d65d52 100644 --- a/examples/request_redraw_threaded.rs +++ b/examples/request_redraw_threaded.rs @@ -27,7 +27,7 @@ fn main() { }); event_loop.run(move |event, _, control_flow| { - println!("{:?}", event); + println!("{event:?}"); *control_flow = ControlFlow::Wait; diff --git a/examples/resizable.rs b/examples/resizable.rs index 617a7b4a3..e0d8c16f2 100644 --- a/examples/resizable.rs +++ b/examples/resizable.rs @@ -40,7 +40,7 @@ fn main() { .. } => { resizable = !resizable; - println!("Resizable: {}", resizable); + println!("Resizable: {resizable}"); window.set_resizable(resizable); } _ => (), diff --git a/examples/timer.rs b/examples/timer.rs index f39b07c51..4ba2d3f71 100644 --- a/examples/timer.rs +++ b/examples/timer.rs @@ -24,7 +24,7 @@ fn main() { let timer_length = Duration::new(1, 0); event_loop.run(move |event, _, control_flow| { - println!("{:?}", event); + println!("{event:?}"); match event { Event::NewEvents(StartCause::Init) => { diff --git a/examples/transparent.rs b/examples/transparent.rs index 6e6b571c7..22c99c9a1 100644 --- a/examples/transparent.rs +++ b/examples/transparent.rs @@ -34,7 +34,7 @@ fn main() { event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Wait; - println!("{:?}", event); + println!("{event:?}"); match event { Event::WindowEvent { diff --git a/examples/video_modes.rs b/examples/video_modes.rs index 79c5a14cc..d40b3f6e3 100644 --- a/examples/video_modes.rs +++ b/examples/video_modes.rs @@ -19,6 +19,6 @@ fn main() { println!("Listing available video modes:"); for mode in monitor.video_modes() { - println!("{}", mode); + println!("{mode}"); } } diff --git a/examples/window.rs b/examples/window.rs index d5d660bf3..c4804fc4c 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -23,7 +23,7 @@ fn main() { event_loop.run(move |event, _, control_flow| { *control_flow = ControlFlow::Wait; - println!("{:?}", event); + println!("{event:?}"); match event { Event::WindowEvent { diff --git a/examples/window_debug.rs b/examples/window_debug.rs index f65002bbe..1bb04c478 100644 --- a/examples/window_debug.rs +++ b/examples/window_debug.rs @@ -124,7 +124,7 @@ fn main() { "r" => { resizable = !resizable; window.set_resizable(resizable); - println!("Resizable: {}", resizable); + println!("Resizable: {resizable}"); } "m" => { window.set_minimized(!window.is_minimized()); diff --git a/src/icon.rs b/src/icon.rs index 7627a9cdf..8827e77bf 100644 --- a/src/icon.rs +++ b/src/icon.rs @@ -47,8 +47,7 @@ impl fmt::Display for BadIcon { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { BadIcon::ByteCountNotDivisibleBy4 { byte_count } => write!(f, - "The length of the `rgba` argument ({:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.", - byte_count, + "The length of the `rgba` argument ({byte_count:?}) isn't divisible by 4, making it impossible to interpret as 32bpp RGBA pixels.", ), BadIcon::DimensionsVsPixelCount { width, @@ -56,24 +55,21 @@ impl fmt::Display for BadIcon { width_x_height, pixel_count, } => write!(f, - "The specified dimensions ({:?}x{:?}) don't match the number of pixels supplied by the `rgba` argument ({:?}). For those dimensions, the expected pixel count is {:?}.", - width, height, pixel_count, width_x_height, + "The specified dimensions ({width:?}x{height:?}) don't match the number of pixels supplied by the `rgba` argument ({pixel_count:?}). For those dimensions, the expected pixel count is {width_x_height:?}.", ), BadIcon::DimensionsZero { width, height, } => write!(f, - "The specified dimensions ({:?}x{:?}) must be greater than zero.", - width, height + "The specified dimensions ({width:?}x{height:?}) must be greater than zero." ), BadIcon::DimensionsMultiplyOverflow { width, height, } => write!(f, - "The specified dimensions multiplication has overflowed ({:?}x{:?}).", - width, height + "The specified dimensions multiplication has overflowed ({width:?}x{height:?})." ), - BadIcon::OsError(e) => write!(f, "OS error when instantiating the icon: {:?}", e), + BadIcon::OsError(e) => write!(f, "OS error when instantiating the icon: {e:?}"), } } } diff --git a/src/keyboard.rs b/src/keyboard.rs index 115d2410c..ac50d42c5 100644 --- a/src/keyboard.rs +++ b/src/keyboard.rs @@ -825,7 +825,7 @@ impl fmt::Display for KeyCode { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { &KeyCode::Unidentified(_) => write!(f, "{:?}", "Unidentified"), - val => write!(f, "{:?}", val), + val => write!(f, "{val:?}"), } } } diff --git a/src/platform/android.rs b/src/platform/android.rs index 4e10b7c51..47b45c76e 100644 --- a/src/platform/android.rs +++ b/src/platform/android.rs @@ -8,9 +8,9 @@ pub mod prelude { pub use crate::platform_impl::ndk_glue::*; pub use tao_macros::{android_fn, generate_package_name}; } -use crate::platform_impl::ndk_glue::Rect; use crate::{ event_loop::{EventLoop, EventLoopWindowTarget}, + platform_impl::ndk_glue::Rect, window::{Window, WindowBuilder}, }; use ndk::configuration::Configuration; diff --git a/src/platform_impl/android/ndk_glue.rs b/src/platform_impl/android/ndk_glue.rs index 5b0de40fb..3b9e89ac2 100644 --- a/src/platform_impl/android/ndk_glue.rs +++ b/src/platform_impl/android/ndk_glue.rs @@ -52,7 +52,7 @@ macro_rules! android_binding { ::tao::android_binding!($domain, $package, $activity, $setup, $main, ::tao) }; ($domain:ident, $package:ident, $activity:ident, $setup:path, $main:ident, $tao:path) => {{ - use $tao::{platform::android::prelude::android_fn, platform::android::prelude::*}; + use $tao::platform::android::prelude::{android_fn, *}; fn _____tao_store_package_name__() { PACKAGE.get_or_init(move || generate_package_name!($domain, $package)); } diff --git a/src/platform_impl/linux/event_loop.rs b/src/platform_impl/linux/event_loop.rs index d5ce7e21b..e5229395d 100644 --- a/src/platform_impl/linux/event_loop.rs +++ b/src/platform_impl/linux/event_loop.rs @@ -1124,8 +1124,7 @@ fn assert_is_main_thread(suggested_method: &str) { is_main_thread(), "Initializing the event loop outside of the main thread is a significant \ cross-platform compatibility hazard. If you really, absolutely need to create an \ - EventLoop on a different thread, please use the `EventLoopExtUnix::{}` function.", - suggested_method + EventLoop on a different thread, please use the `EventLoopExtUnix::{suggested_method}` function." ); } diff --git a/src/platform_impl/linux/keyboard.rs b/src/platform_impl/linux/keyboard.rs index be0198d0d..73ca753ee 100644 --- a/src/platform_impl/linux/keyboard.rs +++ b/src/platform_impl/linux/keyboard.rs @@ -228,7 +228,7 @@ pub(crate) fn make_key_event( }); } else { #[cfg(debug_assertions)] - eprintln!("Couldn't get key from code: {:?}", physical_key); + eprintln!("Couldn't get key from code: {physical_key:?}"); } None } diff --git a/src/platform_impl/linux/util.rs b/src/platform_impl/linux/util.rs index 393932c08..30cd8523b 100644 --- a/src/platform_impl/linux/util.rs +++ b/src/platform_impl/linux/util.rs @@ -3,17 +3,16 @@ use crate::{ error::ExternalError, window::WindowSizeConstraints, }; -use gtk::gdk::{ - self, - prelude::{DeviceExt, SeatExt}, - Display, -}; use gtk::{ + gdk::{ + self, + prelude::{DeviceExt, SeatExt}, + Display, + }, glib::{self}, traits::{GtkWindowExt, WidgetExt}, }; -use std::cell::RefCell; -use std::rc::Rc; +use std::{cell::RefCell, rc::Rc}; #[inline] pub fn cursor_position(is_wayland: bool) -> Result, ExternalError> { diff --git a/src/platform_impl/linux/window.rs b/src/platform_impl/linux/window.rs index 5d988e93a..bcf37e154 100644 --- a/src/platform_impl/linux/window.rs +++ b/src/platform_impl/linux/window.rs @@ -15,8 +15,9 @@ use std::{ use gtk::{ gdk::WindowState, glib::{self, translate::ToGlibPtr}, + prelude::*, + Settings, }; -use gtk::{prelude::*, Settings}; use crate::{ dpi::{LogicalPosition, LogicalSize, PhysicalPosition, PhysicalSize, Position, Size}, diff --git a/src/platform_impl/macos/event_loop.rs b/src/platform_impl/macos/event_loop.rs index 5fd89b86a..df24aed87 100644 --- a/src/platform_impl/macos/event_loop.rs +++ b/src/platform_impl/macos/event_loop.rs @@ -28,15 +28,17 @@ use crate::{ event::Event, event_loop::{ControlFlow, EventLoopClosed, EventLoopWindowTarget as RootWindowTarget}, monitor::MonitorHandle as RootMonitorHandle, - platform_impl::platform::{ - app::APP_CLASS, - app_delegate::APP_DELEGATE_CLASS, - app_state::AppState, - monitor::{self, MonitorHandle}, - observer::*, - util::{self, IdRef}, + platform_impl::{ + platform::{ + app::APP_CLASS, + app_delegate::APP_DELEGATE_CLASS, + app_state::AppState, + monitor::{self, MonitorHandle}, + observer::*, + util::{self, IdRef}, + }, + set_progress_indicator, }, - platform_impl::set_progress_indicator, window::{ProgressBarState, Theme}, }; diff --git a/src/platform_impl/macos/util/mod.rs b/src/platform_impl/macos/util/mod.rs index 63f2892b9..1ffc2049f 100644 --- a/src/platform_impl/macos/util/mod.rs +++ b/src/platform_impl/macos/util/mod.rs @@ -18,8 +18,10 @@ use cocoa::{ foundation::{NSAutoreleasePool, NSPoint, NSRect, NSString, NSUInteger}, }; use core_graphics::display::CGDisplay; -use objc::class; -use objc::runtime::{Class, Object, Sel, BOOL, YES}; +use objc::{ + class, + runtime::{Class, Object, Sel, BOOL, YES}, +}; use crate::{ dpi::{LogicalPosition, PhysicalPosition}, diff --git a/src/platform_impl/macos/window.rs b/src/platform_impl/macos/window.rs index 0564a8f3f..6ac3ab4c0 100644 --- a/src/platform_impl/macos/window.rs +++ b/src/platform_impl/macos/window.rs @@ -21,16 +21,18 @@ use crate::{ icon::Icon, monitor::{MonitorHandle as RootMonitorHandle, VideoMode as RootVideoMode}, platform::macos::WindowExtMacOS, - platform_impl::platform::{ - app_state::AppState, - ffi, - monitor::{self, MonitorHandle, VideoMode}, - util::{self, IdRef}, - view::{self, new_view, CursorState}, - window_delegate::new_delegate, - OsError, + platform_impl::{ + platform::{ + app_state::AppState, + ffi, + monitor::{self, MonitorHandle, VideoMode}, + util::{self, IdRef}, + view::{self, new_view, CursorState}, + window_delegate::new_delegate, + OsError, + }, + set_progress_indicator, }, - platform_impl::set_progress_indicator, window::{ CursorIcon, Fullscreen, ProgressBarState, ResizeDirection, Theme, UserAttentionType, WindowAttributes, WindowId as RootWindowId, WindowSizeConstraints,