From 0df486896b8d106acf65ba83c45cc88d60d228e1 Mon Sep 17 00:00:00 2001 From: MultisampledNight Date: Wed, 15 Dec 2021 21:26:41 +0100 Subject: [PATCH] Fix examples to have an exit code --- examples/control_flow.rs | 2 +- examples/cursor.rs | 2 +- examples/cursor_grab.rs | 4 ++-- examples/custom_events.rs | 2 +- examples/drag_window.rs | 2 +- examples/fullscreen.rs | 4 ++-- examples/handling_close.rs | 2 +- examples/min_max_size.rs | 2 +- examples/minimize.rs | 2 +- examples/mouse_wheel.rs | 2 +- examples/multithreaded.rs | 2 +- examples/multiwindow.rs | 2 +- examples/request_redraw.rs | 2 +- examples/request_redraw_threaded.rs | 2 +- examples/resizable.rs | 2 +- examples/set_ime_position.rs | 2 +- examples/timer.rs | 2 +- examples/transparent.rs | 2 +- examples/web.rs | 2 +- examples/window.rs | 2 +- examples/window_debug.rs | 4 ++-- examples/window_icon.rs | 2 +- examples/window_run_return.rs | 2 +- 23 files changed, 26 insertions(+), 26 deletions(-) diff --git a/examples/control_flow.rs b/examples/control_flow.rs index cbb445eeb..f825bbf16 100644 --- a/examples/control_flow.rs +++ b/examples/control_flow.rs @@ -88,7 +88,7 @@ fn main() { window.request_redraw(); } if close_requested { - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); } } Event::RedrawRequested(_window_id) => {} diff --git a/examples/cursor.rs b/examples/cursor.rs index a466e889a..908af26cc 100644 --- a/examples/cursor.rs +++ b/examples/cursor.rs @@ -42,7 +42,7 @@ fn main() { event: WindowEvent::CloseRequested, .. } => { - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); return; } _ => (), diff --git a/examples/cursor_grab.rs b/examples/cursor_grab.rs index 90a94764d..3aaf1e442 100644 --- a/examples/cursor_grab.rs +++ b/examples/cursor_grab.rs @@ -21,7 +21,7 @@ fn main() { match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), WindowEvent::KeyboardInput { input: KeyboardInput { @@ -33,7 +33,7 @@ fn main() { } => { use winit::event::VirtualKeyCode::*; match key { - Escape => *control_flow = ControlFlow::Exit, + Escape => *control_flow = ControlFlow::Exit(0), G => window.set_cursor_grab(!modifiers.shift()).unwrap(), H => window.set_cursor_visible(modifiers.shift()), _ => (), diff --git a/examples/custom_events.rs b/examples/custom_events.rs index 016754b59..7c04184a7 100644 --- a/examples/custom_events.rs +++ b/examples/custom_events.rs @@ -41,7 +41,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => *control_flow = ControlFlow::Exit, + } => *control_flow = ControlFlow::Exit(0), _ => (), } }); diff --git a/examples/drag_window.rs b/examples/drag_window.rs index a408c7c72..ec7f87fbb 100644 --- a/examples/drag_window.rs +++ b/examples/drag_window.rs @@ -22,7 +22,7 @@ fn main() { eprintln!("Switch which window is to be dragged by pressing \"x\".") } Event::WindowEvent { event, window_id } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), WindowEvent::MouseInput { state: ElementState::Pressed, button: MouseButton::Left, diff --git a/examples/fullscreen.rs b/examples/fullscreen.rs index 83fbde30d..1bdd09480 100644 --- a/examples/fullscreen.rs +++ b/examples/fullscreen.rs @@ -36,7 +36,7 @@ fn main() { match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), WindowEvent::KeyboardInput { input: KeyboardInput { @@ -46,7 +46,7 @@ fn main() { }, .. } => match (virtual_code, state) { - (VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit, + (VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit(0), (VirtualKeyCode::F, ElementState::Pressed) => { if window.fullscreen().is_some() { window.set_fullscreen(None); diff --git a/examples/handling_close.rs b/examples/handling_close.rs index 8334c1773..ebcf77ee5 100644 --- a/examples/handling_close.rs +++ b/examples/handling_close.rs @@ -63,7 +63,7 @@ fn main() { // event loop (i.e. if it's a multi-window application), you need to // drop the window. That closes it, and results in `Destroyed` being // sent. - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); } } N => { diff --git a/examples/min_max_size.rs b/examples/min_max_size.rs index 9a58ed6c6..e30b584e4 100644 --- a/examples/min_max_size.rs +++ b/examples/min_max_size.rs @@ -23,7 +23,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => *control_flow = ControlFlow::Exit, + } => *control_flow = ControlFlow::Exit(0), _ => (), } }); diff --git a/examples/minimize.rs b/examples/minimize.rs index eb02a752c..c6fbd9ec7 100644 --- a/examples/minimize.rs +++ b/examples/minimize.rs @@ -21,7 +21,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => *control_flow = ControlFlow::Exit, + } => *control_flow = ControlFlow::Exit(0), // Keyboard input event to handle minimize via a hotkey Event::WindowEvent { diff --git a/examples/mouse_wheel.rs b/examples/mouse_wheel.rs index e61b64af8..dbed31d32 100644 --- a/examples/mouse_wheel.rs +++ b/examples/mouse_wheel.rs @@ -19,7 +19,7 @@ fn main() { match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), _ => (), }, Event::DeviceEvent { event, .. } => match event { diff --git a/examples/multithreaded.rs b/examples/multithreaded.rs index 68cdb60b7..f6ef5a949 100644 --- a/examples/multithreaded.rs +++ b/examples/multithreaded.rs @@ -148,7 +148,7 @@ fn main() { event_loop.run(move |event, _event_loop, control_flow| { *control_flow = match !window_senders.is_empty() { true => ControlFlow::Wait, - false => ControlFlow::Exit, + false => ControlFlow::Exit(0), }; match event { Event::WindowEvent { event, window_id } => match event { diff --git a/examples/multiwindow.rs b/examples/multiwindow.rs index ec97eee09..abe99d137 100644 --- a/examples/multiwindow.rs +++ b/examples/multiwindow.rs @@ -30,7 +30,7 @@ fn main() { windows.remove(&window_id); if windows.is_empty() { - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); } } WindowEvent::KeyboardInput { diff --git a/examples/request_redraw.rs b/examples/request_redraw.rs index 163f6a14d..a21ed1c9e 100644 --- a/examples/request_redraw.rs +++ b/examples/request_redraw.rs @@ -21,7 +21,7 @@ fn main() { match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), WindowEvent::MouseInput { state: ElementState::Released, .. diff --git a/examples/request_redraw_threaded.rs b/examples/request_redraw_threaded.rs index 7a28c23b5..46f4b356c 100644 --- a/examples/request_redraw_threaded.rs +++ b/examples/request_redraw_threaded.rs @@ -29,7 +29,7 @@ fn main() { match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), _ => (), }, Event::RedrawRequested(_) => { diff --git a/examples/resizable.rs b/examples/resizable.rs index 17892d874..a8e7b37cf 100644 --- a/examples/resizable.rs +++ b/examples/resizable.rs @@ -24,7 +24,7 @@ fn main() { match event { Event::WindowEvent { event, .. } => match event { - WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, + WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0), WindowEvent::KeyboardInput { input: KeyboardInput { diff --git a/examples/set_ime_position.rs b/examples/set_ime_position.rs index 1b2eecc37..a855ec0d9 100644 --- a/examples/set_ime_position.rs +++ b/examples/set_ime_position.rs @@ -45,7 +45,7 @@ fn main() { event: WindowEvent::CloseRequested, .. } => { - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); return; } _ => (), diff --git a/examples/timer.rs b/examples/timer.rs index 7bbb9685f..f9eab55bd 100644 --- a/examples/timer.rs +++ b/examples/timer.rs @@ -33,7 +33,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => *control_flow = ControlFlow::Exit, + } => *control_flow = ControlFlow::Exit(0), _ => (), } }); diff --git a/examples/transparent.rs b/examples/transparent.rs index c9937cd4c..d012b346b 100644 --- a/examples/transparent.rs +++ b/examples/transparent.rs @@ -25,7 +25,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, .. - } => *control_flow = ControlFlow::Exit, + } => *control_flow = ControlFlow::Exit(0), _ => (), } }); diff --git a/examples/web.rs b/examples/web.rs index 83ccc45ee..a47fcd3bf 100644 --- a/examples/web.rs +++ b/examples/web.rs @@ -36,7 +36,7 @@ pub fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => *control_flow = ControlFlow::Exit, + } if window_id == window.id() => *control_flow = ControlFlow::Exit(0), Event::MainEventsCleared => { window.request_redraw(); } diff --git a/examples/window.rs b/examples/window.rs index 783578de6..912d1b5cc 100644 --- a/examples/window.rs +++ b/examples/window.rs @@ -23,7 +23,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => *control_flow = ControlFlow::Exit, + } if window_id == window.id() => *control_flow = ControlFlow::Exit(0), Event::MainEventsCleared => { window.request_redraw(); } diff --git a/examples/window_debug.rs b/examples/window_debug.rs index 577ad5cd7..51523df47 100644 --- a/examples/window_debug.rs +++ b/examples/window_debug.rs @@ -101,7 +101,7 @@ fn main() { window.set_minimized(minimized); } VirtualKeyCode::Q => { - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); } VirtualKeyCode::V => { visible = !visible; @@ -118,7 +118,7 @@ fn main() { Event::WindowEvent { event: WindowEvent::CloseRequested, window_id, - } if window_id == window.id() => *control_flow = ControlFlow::Exit, + } if window_id == window.id() => *control_flow = ControlFlow::Exit(0), _ => (), } }); diff --git a/examples/window_icon.rs b/examples/window_icon.rs index 6c7962550..f1fa428cc 100644 --- a/examples/window_icon.rs +++ b/examples/window_icon.rs @@ -35,7 +35,7 @@ fn main() { if let Event::WindowEvent { event, .. } = event { use winit::event::WindowEvent::*; match event { - CloseRequested => *control_flow = ControlFlow::Exit, + CloseRequested => *control_flow = ControlFlow::Exit(0), DroppedFile(path) => { window.set_window_icon(Some(load_icon(&path))); } diff --git a/examples/window_run_return.rs b/examples/window_run_return.rs index 6bedfcd82..6b7b23f39 100644 --- a/examples/window_run_return.rs +++ b/examples/window_run_return.rs @@ -45,7 +45,7 @@ fn main() { quit = true; } Event::MainEventsCleared => { - *control_flow = ControlFlow::Exit; + *control_flow = ControlFlow::Exit(0); } _ => (), }