On May 29, 2014, at 11:22 AM, Vladimir Matveev <[email protected]> wrote:

> Hi, Christophe,
> 
> Won't wrapping the first `for` loop into curly braces help? I suspect
> this happens because of `for` loop desugaring, which kind of "leaves"
> the iterator created by `execute_query()` "in scope" (not really, but
> only for borrow checker).

It shouldn't.

The for-loop desugaring looks like

match &mut st.execute_query() {
    __i => loop {
        match __i.next() {
            None => break,
            Some(mut __value) => {
                let i = __value;
                {
                    // for loop body goes here
                }
            }
        }
    }
}

It's done with a match statement like this specifically to make the &mut 
binding of the iterator end after the for loop.

-Kevin

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to