-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Window closing implemented return glutin::ControlFlow::Break #8
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
Can also make these changes in main.rs?
@@ -157,6 +157,13 @@ fn main() { | |||
window.show(); | |||
|
|||
event_loop.run_forever(|_event| { | |||
match _event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename _event
to event
.
Adding an underscore in from a variable means it's not used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok.
@@ -157,6 +157,13 @@ fn main() { | |||
window.show(); | |||
|
|||
event_loop.run_forever(|_event| { | |||
match _event { | |||
glutin::Event::WindowEvent { event, .. } => match event { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of event
, you can directly write glutin::WindowEvent::Closed
. Then you have one less match
to use.
@@ -157,6 +157,13 @@ fn main() { | |||
window.show(); | |||
|
|||
event_loop.run_forever(|_event| { | |||
match _event { | |||
glutin::Event::WindowEvent { event, .. } => match event { | |||
glutin::WindowEvent::Closed => return glutin::ControlFlow::Break, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you only have one match, the return
is not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I can not fix it. I just started learning Rust. Rust By Example, or Book. Doesn't help here.
glutin::WindowEvent::Closed => return glutin::ControlFlow::Break, | ||
_ => (), | ||
}, | ||
_ => () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return glutin::ControlFlow::Continue
here.
// Will be use used by Servo later | ||
let event_loop_waker = Box::new(GlutinEventLoopWaker { | ||
let _event_loop_waker = Box::new(GlutinEventLoopWaker { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _
is not necessary.
I don't realy understand what I am doing. But it works now. For me on Ubuntu 16.04