We have:
loop {
break value;
}
'label: loop {
break 'label value;
}
'label: {
break 'label value;
}
It would be nice to extend this to other blocks:
'label: if cond {
break 'label value;
} else {
break 'label value;
}
'label: if let pat = expr {
break 'label value;
} else {
break 'label value;
}
'label: match expr {
pat => {},
}
'label: try {
break 'label value;
}
As opposed to:
'label: {
if cond {
break 'label value;
} else {
break 'label value;
}
}
'label: {
if let pat = expr {
break 'label value;
} else {
break 'label value;
}
}
'label: {
match expr {
pat => {},
}
}
'label: {
try {
break 'label value;
}
}
This avoids a whole level of indentation and an unnecessary pair of {}.
Note that while let and while wouldn't be changed because those can't return values.
(Note that IDEs/rustfmt are unable to cope with:
'label: { if cond {
break 'label value;
} }
Instead, they rewrite it to:
'label: {
if cond {
break 'label value;
}
}
)
We have:
It would be nice to extend this to other blocks:
As opposed to:
This avoids a whole level of indentation and an unnecessary pair of
{}.Note that
while letandwhilewouldn't be changed because those can't return values.(Note that IDEs/rustfmt are unable to cope with:
Instead, they rewrite it to:
)