A bit of syntactic sugar that would allow us to do things like:
// Conditional modifier
let x = 5;
println!("greater than 4") if x > 4;
// Loop modifier
let mut y = 0;
y += 1 while y < 10;
println!("{}", y); // 10
This can easily improve readability. It also might be worth considering the value of 'until' and 'unless' as simplified control constructs.
I didn't like these when I programmed in Ruby and don't want them in Rust. They don't necessarily add ambiguity for the language, but they do add ambiguity for code style. When should someone use these patterns? If someone wants to add an extra line, it requires changing the structure back to a standard block anyway.
I also personally doubt that this improves readability and think that it's only more readable for a subset of native English speakers.
Personally, I find that conditional or loop suffixes add a kind of mental "front-loading" to my internal parser when trying to understand code. It seems far too easy for the modifier to disappear on first glance, making the statement too similar to an unconditional statement.
To put it another way, the log from my internal parser doesn't sound like "print this if condition", it sounds like "print this ... oh, but wait, back up, only do that if condition". The control flow and the text flow don't match up.
In addition, many of the arguments in favor of mandatory braces around blocks apply here.
I also agree with @clarcharr's observation that this makes code changes, refactoring, and maintenance more difficult.
I also should add that Rust has a very specific code aesthetic (yes, I'm calling it that) and this totally looks very different from rust.
It seems exceedingly unlikely that Rust would add this, and there has been no further discussion since January. In the absence of further activity and interest in this proposal, I'm going to go ahead and close it. (That doesn't stop people from discussing it further and perhaps finding some other area of the design space that might be more palatable.)
Most helpful comment
I didn't like these when I programmed in Ruby and don't want them in Rust. They don't necessarily add ambiguity for the language, but they do add ambiguity for code style. When should someone use these patterns? If someone wants to add an extra line, it requires changing the structure back to a standard block anyway.
I also personally doubt that this improves readability and think that it's only more readable for a subset of native English speakers.