Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

dkotrada
Copy link

@dkotrada dkotrada commented Oct 2, 2017

I don't realy understand what I am doing. But it works now. For me on Ubuntu 16.04

Copy link
Owner

@paulrouget paulrouget left a 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 {
Copy link
Owner

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.

Copy link
Author

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 {
Copy link
Owner

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,
Copy link
Owner

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.

Copy link
Author

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,
_ => (),
},
_ => ()
Copy link
Owner

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 {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The _ is not necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants