Add possibility of annotating types in `for`, `while let` and `if let`

Currently, type can be annotated everywhere except for for and the both let loops.

I propose that you can add type annotation there, like this:

for i: i32 in 0..10 { }
while let Some(x): Option<&str> = iter.next() { }
if let Ok(result): Result<bool,()> = function() { }

Thoughts? Can this be added without grammar problems?

2 Likes

https://github.com/rust-lang/rfcs/issues/354

In particular, the section on annotating patterns.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.