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

Can not borrow window in for loop #641

Closed
bvssvni opened this issue Sep 13, 2014 · 5 comments
Closed

Can not borrow window in for loop #641

bvssvni opened this issue Sep 13, 2014 · 5 comments
Labels

Comments

@bvssvni
Copy link
Member

bvssvni commented Sep 13, 2014

This only affects events loops that uses the window.

A breaking change in Rust borrows the iterator for the whole for loop:

rust-lang/rust#17101

Also, see rust-lang/rust#8372

@bvssvni bvssvni added the bug label Sep 13, 2014
@bvssvni
Copy link
Member Author

bvssvni commented Sep 13, 2014

This is a bug in Rust and not in Piston.

In the mean time, we'll use loop and a match expression:

loop {
    let e = match event_iter.next() {
        None => { break; }
        Some(e) => e
    };

    // Handle event here.
}

@TyOverby
Copy link
Contributor

Isn't it also a problem that EventIterator borrows window mutably basically preventing you from using window anyway?

@TyOverby
Copy link
Contributor

This code used to compile, how did it work before? Is the breakage related to this bug?
https://github.com/TyOverby/Piston-Tutorials/blob/master/getting-started/src/main.rs#L71-L77

@bvssvni
Copy link
Member Author

bvssvni commented Sep 19, 2014

@TyOverby Use event_iter.window

@TyOverby
Copy link
Contributor

Thanks Sven!

On Thu, Sep 18, 2014 at 11:20 PM, Sven Nilsen notifications@github.com
wrote:

@TyOverby https://github.com/TyOverby Use event_iter.window


Reply to this email directly or view it on GitHub
#641 (comment)
.

-Ty Overby
:wq

@bvssvni bvssvni closed this as completed Oct 28, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants