Let vfrmt allow not new line when only one line something like
for i in 0..10 {
if i == x { continue }
do somthing..
}
I think it's more readable.
No, there's no point in this. It goes against the one way philosophy, makes it harder to add more statements, and complicates vfmt.
But why we have two options for e.g. or-blocks then?
... or { ... }
and
func() or {
...
...
}
I vote for compactness when it's so short expressions. It's still one way if it's containing only a keyword that changes execution path/scope? (return, continue, break etc.)
if please { continue } :+1:
I have to agree with Alex.
As he said, it makes it harder to add more statements. Visually, at least.
If I have
if please { do1thing }
in my code, and I want to add maybe in the block, I can either do this
if please { do1thing maybe }
In which case vfmt will expand it to multiple lines
if please {
do1thing
maybe
}
or I have to reformat it manually.
We're not on paper any longer - we don't have to save lines to avoid going to another sheet for just one or 2 lines of print.
I vote for forcing one-line if's like this to the standard multi-line format, rather than forcing "short" if's (and who gets to define short?) onto one line. Really. It's only 2 more lines to expand it, and can save headaches if you need to add more statements in the if block.
how about just in case of break, continue, return (nothing)?
the reason of suggested is mainly editor (vscode) folding.
event though it contains just a break, editor folding hide it.
it makes me think what is in this {} body?
and expand it found nothing, oh..
that is why I said for readability.
This feature is really handy and makes the code more readable IMO. If we have foo or { /* do something */ } then why not this?
Well I was against that as well, but in or { } blocks in a vast majority of cases there's only one statement.
Most helpful comment
I vote for compactness when it's so short expressions. It's still one way if it's containing only a keyword that changes execution path/scope? (
return,continue,breaketc.)if please { continue }:+1: