for + await loops have been discussed, and no consensus emerged (awaiting a future is kinda similar to unwrapping a result). In for <pattern> in <expr> there's not much room to insert any new action that isn't ambiguous or confusing with either patterns or expressions.
I'm not sure what you mean by for x in try, as AFAIK that would iterate over Result which is an odd quirk that just visits the single Ok value. Do you mean loops with let x = x?; pattern?
Oh yes, sorry, that's what I meant, I'll update the post. for await was left as a future extension in the async/await rfc, meant for streams/async iterators.
A problem with this proposal is that a impl Iterator<Item=Result<_, _>> type suggests that the iterator may continue yielding elements after an Err(_) is returned, but this syntax leaves little room for processing them. If the iterator type clearly communicated that no further elements can be returned after an Err, this would not be such a problem.
A while ago, I came up with this design, as part of a larger proposal (first sketched in this thread), but it could be adopted mostly independently of the larger one.
Thinking about this more, maybe it's not the intended, only, or best design for a for try loop. What about allowing ? to be used as a pattern? The following would accomplish the same thing and is pretty straightforward:
The only loop improvement we can think of is something that lets you both iterate and apply stuff to the value, i.e. sugar for the following:
for [name] in [iterator] {
let [name] = [operations];
}
but we can't imagine such a thing being a good fit for rust.
We can imagine something like these, but we think they look kinda weird:
for x become x? in iterator {
}
for x become foo(x) in iterator {
}
// etc
mostly because they're declaring two bindings, but using the same identifier token (i.e. the literal token, in the source file) for both. Nevertheless, these are basically like using .map(|x| x...) but without introducing a closure scope.
You could argue this has the advantage of keeping everything in the same line, but we see that as a disadvantage because we actually try to keep to 80 columns. Additionally, this still introduces a depth of indentation, so... we don't see what you're trying to gain from this? What do you see that we don't see?
No, it's an argument against heavily non-obvious syntactic sugar that doesn't accomplish much in terms of expressive power. The already-existing alternatives are all trivial — so there isn't a lot of value in adding this kind of nee syntax.