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();
}
if close_requested {
*control_flow = ControlFlow::Exit;
*control_flow = ControlFlow::Exit(0);
}
}
Event::RedrawRequested(_window_id) => {}

View File

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

View File

@@ -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()),
_ => (),

View File

@@ -41,7 +41,7 @@ fn main() {
Event::WindowEvent {
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\".")
}
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,

View File

@@ -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);

View File

@@ -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 => {

View File

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

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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 {

View File

@@ -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,
..

View File

@@ -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(_) => {

View File

@@ -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 {

View File

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

View File

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

View File

@@ -25,7 +25,7 @@ fn main() {
Event::WindowEvent {
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::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();
}

View File

@@ -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();
}

View File

@@ -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),
_ => (),
}
});

View File

@@ -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)));
}

View File

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