News for hackers. Stuff that matters.
Re:Rust for C++ programmers – part 2: control flow by masklinn on Sunday April 20, 2014 @04:07AM (#7616212)
> You'd have to overload "for" to detect whether the expression implemented Iterable or Iterator to decide what to do

Iterator implements Iterable as a trivial self-return (by default), and `for` only and always takes an Iterable?

> what if you implement both?

Depends what sort of weirdness you're trying to do I guess.

> I believe it didn't work with the trait matching rules.

Ah. Too bad.

Re:Rust for C++ programmers – part 2: control flow by pcwalton on Sunday April 20, 2014 @04:11AM (#7616216)
Yeah, I would rather have "for" defined only to operate on Iterables. If we modified the trait matching rules we could probably do that backwards compatibly post 1.0.