On Tue, Oct 23, 2012 at 5:35 PM, Benjamin Striegel
<ben.strie...@gmail.com> wrote:
> Because of the special treatment of `for` loops in Rust, I'd need a more
> specific example of what you're trying to do.

Looping over a part of an array by index and moving on immediately
when a “not interested” condition matches.

Stuff like
for (int i = start; i < end; i++) {
  char c = buf[i];
  ...
  if (c == uninteresting) {
    continue;
  }
  ...
}

On Tue, Oct 23, 2012 at 9:21 PM, Brian Anderson <bander...@mozilla.com> wrote:
> I'm assuming
> you need to do this with `loop` specifically for the HTML parser (since that
> is the only looping construct rust is currently implementing labeled
> break/continue for).

The HTML parser breaks/continues by label only with “infinite” loop.
The loops with an index variable are not continued/broken by label.

> It's not pretty, but maybe good enough for transpiling?

Yeah, not pretty. I think the simplest solution is to transform the
Java “for” loops that have an update expression into Rust “while”
loops and copy the update expression to the end of the loop and to
before each loop; statement. (And then maybe changing the Java source
over time to make this pattern occur less.)

(Aside: Now that Rust has both loop { } and loop;, talking about the
“loop statement” would be ambiguous.)

-- 
Henri Sivonen
hsivo...@iki.fi
http://hsivonen.iki.fi/
_______________________________________________
Rust-dev mailing list
Rust-dev@mozilla.org
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to