Fix examples to have an exit code

This commit is contained in:
MultisampledNight
2021-12-15 21:26:41 +01:00
parent ebf669a91f
commit 0df486896b
23 changed files with 26 additions and 26 deletions

View File

@@ -88,7 +88,7 @@ fn main() {
window.request_redraw(); window.request_redraw();
} }
if close_requested { if close_requested {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
} }
} }
Event::RedrawRequested(_window_id) => {} Event::RedrawRequested(_window_id) => {}

View File

@@ -42,7 +42,7 @@ fn main() {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => { } => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
return; return;
} }
_ => (), _ => (),

View File

@@ -21,7 +21,7 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0),
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: input:
KeyboardInput { KeyboardInput {
@@ -33,7 +33,7 @@ fn main() {
} => { } => {
use winit::event::VirtualKeyCode::*; use winit::event::VirtualKeyCode::*;
match key { match key {
Escape => *control_flow = ControlFlow::Exit, Escape => *control_flow = ControlFlow::Exit(0),
G => window.set_cursor_grab(!modifiers.shift()).unwrap(), G => window.set_cursor_grab(!modifiers.shift()).unwrap(),
H => window.set_cursor_visible(modifiers.shift()), H => window.set_cursor_visible(modifiers.shift()),
_ => (), _ => (),

View File

@@ -41,7 +41,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => *control_flow = ControlFlow::Exit, } => *control_flow = ControlFlow::Exit(0),
_ => (), _ => (),
} }
}); });

View File

@@ -22,7 +22,7 @@ fn main() {
eprintln!("Switch which window is to be dragged by pressing \"x\".") eprintln!("Switch which window is to be dragged by pressing \"x\".")
} }
Event::WindowEvent { event, window_id } => match event { Event::WindowEvent { event, window_id } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0),
WindowEvent::MouseInput { WindowEvent::MouseInput {
state: ElementState::Pressed, state: ElementState::Pressed,
button: MouseButton::Left, button: MouseButton::Left,

View File

@@ -36,7 +36,7 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0),
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: input:
KeyboardInput { KeyboardInput {
@@ -46,7 +46,7 @@ fn main() {
}, },
.. ..
} => match (virtual_code, state) { } => match (virtual_code, state) {
(VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit, (VirtualKeyCode::Escape, _) => *control_flow = ControlFlow::Exit(0),
(VirtualKeyCode::F, ElementState::Pressed) => { (VirtualKeyCode::F, ElementState::Pressed) => {
if window.fullscreen().is_some() { if window.fullscreen().is_some() {
window.set_fullscreen(None); window.set_fullscreen(None);

View File

@@ -63,7 +63,7 @@ fn main() {
// event loop (i.e. if it's a multi-window application), you need to // 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 // drop the window. That closes it, and results in `Destroyed` being
// sent. // sent.
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
} }
} }
N => { N => {

View File

@@ -23,7 +23,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => *control_flow = ControlFlow::Exit, } => *control_flow = ControlFlow::Exit(0),
_ => (), _ => (),
} }
}); });

View File

@@ -21,7 +21,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => *control_flow = ControlFlow::Exit, } => *control_flow = ControlFlow::Exit(0),
// Keyboard input event to handle minimize via a hotkey // Keyboard input event to handle minimize via a hotkey
Event::WindowEvent { Event::WindowEvent {

View File

@@ -19,7 +19,7 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => 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 { Event::DeviceEvent { event, .. } => match event {

View File

@@ -148,7 +148,7 @@ fn main() {
event_loop.run(move |event, _event_loop, control_flow| { event_loop.run(move |event, _event_loop, control_flow| {
*control_flow = match !window_senders.is_empty() { *control_flow = match !window_senders.is_empty() {
true => ControlFlow::Wait, true => ControlFlow::Wait,
false => ControlFlow::Exit, false => ControlFlow::Exit(0),
}; };
match event { match event {
Event::WindowEvent { event, window_id } => match event { Event::WindowEvent { event, window_id } => match event {

View File

@@ -30,7 +30,7 @@ fn main() {
windows.remove(&window_id); windows.remove(&window_id);
if windows.is_empty() { if windows.is_empty() {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
} }
} }
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {

View File

@@ -21,7 +21,7 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0),
WindowEvent::MouseInput { WindowEvent::MouseInput {
state: ElementState::Released, state: ElementState::Released,
.. ..

View File

@@ -29,7 +29,7 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0),
_ => (), _ => (),
}, },
Event::RedrawRequested(_) => { Event::RedrawRequested(_) => {

View File

@@ -24,7 +24,7 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => match event { Event::WindowEvent { event, .. } => match event {
WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit, WindowEvent::CloseRequested => *control_flow = ControlFlow::Exit(0),
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: input:
KeyboardInput { KeyboardInput {

View File

@@ -45,7 +45,7 @@ fn main() {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => { } => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
return; return;
} }
_ => (), _ => (),

View File

@@ -33,7 +33,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => *control_flow = ControlFlow::Exit, } => *control_flow = ControlFlow::Exit(0),
_ => (), _ => (),
} }
}); });

View File

@@ -25,7 +25,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
.. ..
} => *control_flow = ControlFlow::Exit, } => *control_flow = ControlFlow::Exit(0),
_ => (), _ => (),
} }
}); });

View File

@@ -36,7 +36,7 @@ pub fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
window_id, window_id,
} if window_id == window.id() => *control_flow = ControlFlow::Exit, } if window_id == window.id() => *control_flow = ControlFlow::Exit(0),
Event::MainEventsCleared => { Event::MainEventsCleared => {
window.request_redraw(); window.request_redraw();
} }

View File

@@ -23,7 +23,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
window_id, window_id,
} if window_id == window.id() => *control_flow = ControlFlow::Exit, } if window_id == window.id() => *control_flow = ControlFlow::Exit(0),
Event::MainEventsCleared => { Event::MainEventsCleared => {
window.request_redraw(); window.request_redraw();
} }

View File

@@ -101,7 +101,7 @@ fn main() {
window.set_minimized(minimized); window.set_minimized(minimized);
} }
VirtualKeyCode::Q => { VirtualKeyCode::Q => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
} }
VirtualKeyCode::V => { VirtualKeyCode::V => {
visible = !visible; visible = !visible;
@@ -118,7 +118,7 @@ fn main() {
Event::WindowEvent { Event::WindowEvent {
event: WindowEvent::CloseRequested, event: WindowEvent::CloseRequested,
window_id, window_id,
} if window_id == window.id() => *control_flow = ControlFlow::Exit, } if window_id == window.id() => *control_flow = ControlFlow::Exit(0),
_ => (), _ => (),
} }
}); });

View File

@@ -35,7 +35,7 @@ fn main() {
if let Event::WindowEvent { event, .. } = event { if let Event::WindowEvent { event, .. } = event {
use winit::event::WindowEvent::*; use winit::event::WindowEvent::*;
match event { match event {
CloseRequested => *control_flow = ControlFlow::Exit, CloseRequested => *control_flow = ControlFlow::Exit(0),
DroppedFile(path) => { DroppedFile(path) => {
window.set_window_icon(Some(load_icon(&path))); window.set_window_icon(Some(load_icon(&path)));
} }

View File

@@ -45,7 +45,7 @@ fn main() {
quit = true; quit = true;
} }
Event::MainEventsCleared => { Event::MainEventsCleared => {
*control_flow = ControlFlow::Exit; *control_flow = ControlFlow::Exit(0);
} }
_ => (), _ => (),
} }