Skip to content

Commit

Permalink
Fix clippy issues on stable
Browse files Browse the repository at this point in the history
  • Loading branch information
kchibisov committed Jan 27, 2023
1 parent e1b7fda commit 930df0e
Show file tree
Hide file tree
Showing 36 changed files with 68 additions and 76 deletions.
6 changes: 3 additions & 3 deletions examples/child_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn main() {

let id = child_window.id();
windows.insert(id, child_window);
println!("child window created with id: {:?}", id);
println!("child window created with id: {id:?}");
}

let mut windows = HashMap::new();
Expand All @@ -40,7 +40,7 @@ fn main() {
.build(&event_loop)
.unwrap();

println!("parent window: {:?})", parent_window);
println!("parent window: {parent_window:?})");

event_loop.run(move |event: Event<'_, ()>, event_loop, control_flow| {
*control_flow = ControlFlow::Wait;
Expand All @@ -56,7 +56,7 @@ fn main() {
// by some key inputs.
// the child windows are always placed at (0, 0) with size (200, 200) in the parent window,
// so we also can see this log when we move the cursor arround (200, 200) in parent window.
println!("cursor entered in the window {:?}", window_id);
println!("cursor entered in the window {window_id:?}");
}
WindowEvent::KeyboardInput {
input:
Expand Down
10 changes: 5 additions & 5 deletions examples/control_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fn main() {

event_loop.run(move |event, _, control_flow| {
use winit::event::{ElementState, StartCause, VirtualKeyCode};
println!("{:?}", event);
println!("{event:?}");
match event {
Event::NewEvents(start_cause) => {
wait_cancelled = match start_cause {
Expand All @@ -64,19 +64,19 @@ fn main() {
} => match virtual_code {
VirtualKeyCode::Key1 => {
mode = Mode::Wait;
println!("\nmode: {:?}\n", mode);
println!("\nmode: {mode:?}\n");
}
VirtualKeyCode::Key2 => {
mode = Mode::WaitUntil;
println!("\nmode: {:?}\n", mode);
println!("\nmode: {mode:?}\n");
}
VirtualKeyCode::Key3 => {
mode = Mode::Poll;
println!("\nmode: {:?}\n", mode);
println!("\nmode: {mode:?}\n");
}
VirtualKeyCode::R => {
request_redraw = !request_redraw;
println!("\nrequest_redraw: {}\n", request_redraw);
println!("\nrequest_redraw: {request_redraw}\n");
}
VirtualKeyCode::Escape => {
close_requested = true;
Expand Down
8 changes: 4 additions & 4 deletions examples/cursor_grab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ fn main() {
};

if let Err(err) = result {
println!("error: {}", err);
println!("error: {err}");
}
}
WindowEvent::ModifiersChanged(m) => modifiers = m,
_ => (),
},
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"),
},
_ => (),
},
Expand Down
2 changes: 1 addition & 1 deletion examples/custom_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() {
control_flow.set_wait();

match event {
Event::UserEvent(event) => println!("user event: {:?}", event),
Event::UserEvent(event) => println!("user event: {event:?}"),
Event::WindowEvent {
event: WindowEvent::CloseRequested,
..
Expand Down
10 changes: 5 additions & 5 deletions examples/fullscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() {

let mut mode_index = 0;
let mut mode = monitor.video_modes().next().expect("no mode found");
println!("Mode: {}", mode);
println!("Mode: {mode}");

println!("Keys:");
println!("- Esc\tExit");
Expand Down Expand Up @@ -59,12 +59,12 @@ fn main() {
}
VirtualKeyCode::F => {
let fullscreen = Some(Fullscreen::Exclusive(mode.clone()));
println!("Setting mode: {:?}", fullscreen);
println!("Setting mode: {fullscreen:?}");
window.set_fullscreen(fullscreen);
}
VirtualKeyCode::B => {
let fullscreen = Some(Fullscreen::Borderless(Some(monitor.clone())));
println!("Setting mode: {:?}", fullscreen);
println!("Setting mode: {fullscreen:?}");
window.set_fullscreen(fullscreen);
}
VirtualKeyCode::S => {
Expand All @@ -79,7 +79,7 @@ fn main() {

mode_index = 0;
mode = monitor.video_modes().next().expect("no mode found");
println!("Mode: {}", mode);
println!("Mode: {mode}");
}
VirtualKeyCode::M => {
mode_index += 1;
Expand All @@ -89,7 +89,7 @@ fn main() {
mode_index = 0;
mode = monitor.video_modes().next().expect("no mode found");
}
println!("Mode: {}", mode);
println!("Mode: {mode}");
}
VirtualKeyCode::D => {
decorations = !decorations;
Expand Down
8 changes: 4 additions & 4 deletions examples/ime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ fn main() {
event: WindowEvent::Ime(event),
..
} => {
println!("{:?}", event);
println!("{event:?}");
may_show_ime = event != Ime::Disabled;
if may_show_ime {
window.set_ime_position(ime_pos);
Expand All @@ -77,20 +77,20 @@ fn main() {
event: WindowEvent::ReceivedCharacter(ch),
..
} => {
println!("ch: {:?}", ch);
println!("ch: {ch:?}");
}
Event::WindowEvent {
event: WindowEvent::KeyboardInput { input, .. },
..
} => {
println!("key: {:?}", input);
println!("key: {input:?}");

if input.state == ElementState::Pressed
&& input.virtual_keycode == Some(VirtualKeyCode::F2)
{
ime_allowed = !ime_allowed;
window.set_ime_allowed(ime_allowed);
println!("\nIME: {}\n", ime_allowed);
println!("\nIME: {ime_allowed}\n");
}
}
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion examples/mouse_wheel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ In other words, the deltas indicate the direction in which to move the content (
WindowEvent::CloseRequested => control_flow.set_exit(),
WindowEvent::MouseWheel { delta, .. } => match delta {
winit::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;
Expand Down
8 changes: 4 additions & 4 deletions examples/multithreaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fn main() {
},
..
} => {
window.set_title(&format!("{:?}", key));
window.set_title(&format!("{key:?}"));
let state = !modifiers.shift();
use VirtualKeyCode::*;
match key {
Expand Down Expand Up @@ -92,17 +92,17 @@ fn main() {
}),
L if state => {
if let Err(err) = window.set_cursor_grab(CursorGrabMode::Locked) {
println!("error: {}", err);
println!("error: {err}");
}
}
G if state => {
if let Err(err) = window.set_cursor_grab(CursorGrabMode::Confined) {
println!("error: {}", err);
println!("error: {err}");
}
}
G | L if !state => {
if let Err(err) = window.set_cursor_grab(CursorGrabMode::None) {
println!("error: {}", err);
println!("error: {err}");
}
}
H => window.set_cursor_visible(!state),
Expand Down
2 changes: 1 addition & 1 deletion examples/multiwindow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn main() {
Event::WindowEvent { event, window_id } => {
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);
Expand Down
2 changes: 1 addition & 1 deletion examples/request_redraw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ fn main() {
.unwrap();

event_loop.run(move |event, _, control_flow| {
println!("{:?}", event);
println!("{event:?}");

control_flow.set_wait();

Expand Down
2 changes: 1 addition & 1 deletion examples/request_redraw_threaded.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ fn main() {
});

event_loop.run(move |event, _, control_flow| {
println!("{:?}", event);
println!("{event:?}");

control_flow.set_wait();

Expand Down
2 changes: 1 addition & 1 deletion examples/resizable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() {
..
} => {
resizable = !resizable;
println!("Resizable: {}", resizable);
println!("Resizable: {resizable}");
window.set_resizable(resizable);
}
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion examples/theme.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() {
window_id,
..
} if window_id == window.id() => {
println!("Theme is changed: {:?}", theme)
println!("Theme is changed: {theme:?}")
}
Event::WindowEvent {
event:
Expand Down
2 changes: 1 addition & 1 deletion examples/timer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,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) => {
Expand Down
8 changes: 4 additions & 4 deletions examples/touchpad_gestures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@ fn main() {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit,
WindowEvent::TouchpadMagnify { delta, .. } => {
if delta > 0.0 {
println!("Zoomed in {}", delta);
println!("Zoomed in {delta}");
} else {
println!("Zoomed out {}", delta);
println!("Zoomed out {delta}");
}
}
WindowEvent::SmartMagnify { .. } => {
println!("Smart zoom");
}
WindowEvent::TouchpadRotate { delta, .. } => {
if delta > 0.0 {
println!("Rotated counterclockwise {}", delta);
println!("Rotated counterclockwise {delta}");
} else {
println!("Rotated clockwise {}", delta);
println!("Rotated clockwise {delta}");
}
}
_ => (),
Expand Down
2 changes: 1 addition & 1 deletion examples/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {

event_loop.run(move |event, _, control_flow| {
control_flow.set_wait();
println!("{:?}", event);
println!("{event:?}");

match event {
Event::WindowEvent {
Expand Down
2 changes: 1 addition & 1 deletion examples/video_modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ fn main() {
println!("Listing available video modes:");

for mode in monitor.video_modes() {
println!("{}", mode);
println!("{mode}");
}
}
2 changes: 1 addition & 1 deletion examples/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ mod wasm {
let window = web_sys::window().unwrap();
let document = window.document().unwrap();
let log = document.create_element("li").unwrap();
log.set_text_content(Some(&format!("{:?}", event)));
log.set_text_content(Some(&format!("{event:?}")));
log_list
.insert_before(&log, log_list.first_child().as_ref())
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() {

event_loop.run(move |event, _, control_flow| {
control_flow.set_wait();
println!("{:?}", event);
println!("{event:?}");

match event {
Event::WindowEvent {
Expand Down
2 changes: 1 addition & 1 deletion examples/window_run_return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn main() {

if let Event::WindowEvent { event, .. } = &event {
// Print only Window events to reduce noise
println!("{:?}", event);
println!("{event:?}");
}

match event {
Expand Down
8 changes: 3 additions & 5 deletions src/icon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,17 @@ 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,
height,
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::OsError(e) => write!(f, "OS error when instantiating the icon: {:?}", e),
BadIcon::OsError(e) => write!(f, "OS error when instantiating the icon: {e:?}"),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/platform_impl/android/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,10 @@ impl<T: 'static> EventLoop<T> {
}
}

fn single_iteration<'a, F>(
fn single_iteration<F>(
&mut self,
control_flow: &mut ControlFlow,
main_event: Option<MainEvent<'a>>,
main_event: Option<MainEvent<'_>>,
pending_redraw: &mut bool,
cause: &mut StartCause,
callback: &mut F,
Expand Down
6 changes: 2 additions & 4 deletions src/platform_impl/linux/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -727,8 +727,7 @@ impl<T: 'static> EventLoop<T> {
panic!("wayland feature is not enabled");
}
_ => panic!(
"Unknown environment variable value for {}, try one of `x11`,`wayland`",
BACKEND_PREFERENCE_ENV_VAR,
"Unknown environment variable value for {BACKEND_PREFERENCE_ENV_VAR}, try one of `x11`,`wayland`",
),
}
}
Expand All @@ -751,8 +750,7 @@ impl<T: 'static> EventLoop<T> {
let x11_err = "backend disabled";

panic!(
"Failed to initialize any backend! Wayland status: {:?} X11 status: {:?}",
wayland_err, x11_err,
"Failed to initialize any backend! Wayland status: {wayland_err:?} X11 status: {x11_err:?}",
);
}

Expand Down
Loading

0 comments on commit 930df0e

Please sign in to comment.