Rename ControlFlow variant from Complete to Break

This commit is contained in:
mitchmindtree 2017-06-20 21:25:53 +10:00
parent df1276d72a
commit 04ccad1dbc
13 changed files with 28 additions and 28 deletions

View file

@ -23,7 +23,7 @@ fn main() {
} }
}, },
Event::WindowEvent { event: WindowEvent::Closed, .. } => { Event::WindowEvent { event: WindowEvent::Closed, .. } => {
return ControlFlow::Complete; return ControlFlow::Break;
}, },
_ => () _ => ()
} }

View file

@ -37,10 +37,10 @@ fn main() {
match event { match event {
Event::WindowEvent { event, .. } => { Event::WindowEvent { event, .. } => {
match event { match event {
WindowEvent::Closed => return ControlFlow::Complete, WindowEvent::Closed => return ControlFlow::Break,
WindowEvent::KeyboardInput { WindowEvent::KeyboardInput {
input: winit::KeyboardInput { virtual_keycode: Some(winit::VirtualKeyCode::Escape), .. }, .. input: winit::KeyboardInput { virtual_keycode: Some(winit::VirtualKeyCode::Escape), .. }, ..
} => return ControlFlow::Complete, } => return ControlFlow::Break,
_ => () _ => ()
} }
}, },

View file

@ -28,7 +28,7 @@ fn main() {
} }
}, },
WindowEvent::Closed => return ControlFlow::Complete, WindowEvent::Closed => return ControlFlow::Break,
a @ WindowEvent::MouseMoved { .. } => { a @ WindowEvent::MouseMoved { .. } => {
println!("{:?}", a); println!("{:?}", a);

View file

@ -13,7 +13,7 @@ fn main() {
println!("{:?}", event); println!("{:?}", event);
match event { match event {
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Complete, winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Break,
_ => winit::ControlFlow::Continue, _ => winit::ControlFlow::Continue,
} }
}); });

View file

@ -24,7 +24,7 @@ fn main() {
num_windows -= 1; num_windows -= 1;
if num_windows == 0 { if num_windows == 0 {
return winit::ControlFlow::Complete; return winit::ControlFlow::Break;
} }
}, },
_ => (), _ => (),

View file

@ -22,7 +22,7 @@ fn main() {
println!("{:?}", event); println!("{:?}", event);
match event { match event {
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } =>
winit::ControlFlow::Complete, winit::ControlFlow::Break,
_ => winit::ControlFlow::Continue, _ => winit::ControlFlow::Continue,
} }
}); });

View file

@ -13,7 +13,7 @@ fn main() {
println!("{:?}", event); println!("{:?}", event);
match event { match event {
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Complete, winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => winit::ControlFlow::Break,
_ => winit::ControlFlow::Continue, _ => winit::ControlFlow::Continue,
} }
}); });

View file

@ -13,7 +13,7 @@ fn main() {
match event { match event {
winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => { winit::Event::WindowEvent { event: winit::WindowEvent::Closed, .. } => {
winit::ControlFlow::Complete winit::ControlFlow::Break
}, },
_ => winit::ControlFlow::Continue, _ => winit::ControlFlow::Continue,
} }

View file

@ -52,11 +52,11 @@ macro_rules! gen_api_transition {
loop { loop {
let mut control_flow = ::ControlFlow::Continue; let mut control_flow = ::ControlFlow::Continue;
self.poll_events(|e| { self.poll_events(|e| {
if let ::ControlFlow::Complete = callback(e) { if let ::ControlFlow::Break = callback(e) {
control_flow = ::ControlFlow::Complete; control_flow = ::ControlFlow::Break;
} }
}); });
if let ::ControlFlow::Complete = control_flow { if let ::ControlFlow::Break = control_flow {
break; break;
} }
::std::thread::sleep(::std::time::Duration::from_millis(5)); ::std::thread::sleep(::std::time::Duration::from_millis(5));

View file

@ -51,7 +51,7 @@
//! ``` //! ```
//! //!
//! The second way is to call `events_loop.run_forever(...)`. As its name tells, it will run //! The second way is to call `events_loop.run_forever(...)`. As its name tells, it will run
//! forever unless it is stopped by returning `ControlFlow::Complete`. //! forever unless it is stopped by returning `ControlFlow::Break`.
//! //!
//! ```no_run //! ```no_run
//! use winit::{ControlFlow, Event, WindowEvent}; //! use winit::{ControlFlow, Event, WindowEvent};
@ -62,7 +62,7 @@
//! match event { //! match event {
//! Event::WindowEvent { event: WindowEvent::Closed, .. } => { //! Event::WindowEvent { event: WindowEvent::Closed, .. } => {
//! println!("The window was closed ; stopping"); //! println!("The window was closed ; stopping");
//! ControlFlow::Complete //! ControlFlow::Break
//! }, //! },
//! _ => ControlFlow::Continue, //! _ => ControlFlow::Continue,
//! } //! }
@ -143,7 +143,7 @@ pub mod os;
/// events_loop.run_forever(|event| { /// events_loop.run_forever(|event| {
/// match event { /// match event {
/// Event::WindowEvent { event: WindowEvent::Closed, .. } => { /// Event::WindowEvent { event: WindowEvent::Closed, .. } => {
/// ControlFlow::Complete /// ControlFlow::Break
/// }, /// },
/// _ => ControlFlow::Continue, /// _ => ControlFlow::Continue,
/// } /// }
@ -192,8 +192,8 @@ pub struct EventsLoop {
pub enum ControlFlow { pub enum ControlFlow {
/// Continue looping and waiting for events. /// Continue looping and waiting for events.
Continue, Continue,
/// Exit from the event loop. /// Break from the event loop.
Complete, Break,
} }
impl EventsLoop { impl EventsLoop {

View file

@ -226,8 +226,8 @@ impl EventsLoop {
// Check for control flow by wrapping the callback. // Check for control flow by wrapping the callback.
let control_flow = ::std::cell::Cell::new(ControlFlow::Continue); let control_flow = ::std::cell::Cell::new(ControlFlow::Continue);
let callback = |event| if let ControlFlow::Complete = callback(event) { let callback = |event| if let ControlFlow::Break = callback(event) {
control_flow.set(ControlFlow::Complete); control_flow.set(ControlFlow::Break);
}; };
// set the callback into the sink // set the callback into the sink
@ -251,7 +251,7 @@ impl EventsLoop {
self.prune_dead_windows() self.prune_dead_windows()
} }
if let ControlFlow::Complete = control_flow.get() { if let ControlFlow::Break = control_flow.get() {
break; break;
} }
} }

View file

@ -163,18 +163,18 @@ impl EventsLoop {
let mut control_flow = ControlFlow::Continue; let mut control_flow = ControlFlow::Continue;
// Track whether or not `Complete` was returned when processing the event. // Track whether or not `Break` was returned when processing the event.
{ {
let mut cb = |event| { let mut cb = |event| {
if let ControlFlow::Complete = callback(event) { if let ControlFlow::Break = callback(event) {
control_flow = ControlFlow::Complete; control_flow = ControlFlow::Break;
} }
}; };
self.process_event(&mut xev, &mut cb); self.process_event(&mut xev, &mut cb);
} }
if let ControlFlow::Complete = control_flow { if let ControlFlow::Break = control_flow {
break; break;
} }
} }

View file

@ -222,8 +222,8 @@ impl EventsLoop {
let control_flow = std::cell::Cell::new(ControlFlow::Continue); let control_flow = std::cell::Cell::new(ControlFlow::Continue);
let mut callback = |event| { let mut callback = |event| {
if let ControlFlow::Complete = callback(event) { if let ControlFlow::Break = callback(event) {
control_flow.set(ControlFlow::Complete); control_flow.set(ControlFlow::Break);
} }
}; };
@ -233,7 +233,7 @@ impl EventsLoop {
unsafe { unsafe {
// First, yield all pending events. // First, yield all pending events.
self.shared.call_user_callback_with_pending_events(); self.shared.call_user_callback_with_pending_events();
if let ControlFlow::Complete = control_flow.get() { if let ControlFlow::Break = control_flow.get() {
break; break;
} }
@ -254,7 +254,7 @@ impl EventsLoop {
if let Some(event) = maybe_event { if let Some(event) = maybe_event {
self.shared.user_callback.call_with_event(event); self.shared.user_callback.call_with_event(event);
if let ControlFlow::Complete = control_flow.get() { if let ControlFlow::Break = control_flow.get() {
break; break;
} }
} }