-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Closed
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.
Description
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;
}
})
MingweiSamuellilydjwg and scottmcm
Metadata
Metadata
Assignees
Labels
T-langRelevant to the language team, which will review and decide on the RFC.Relevant to the language team, which will review and decide on the RFC.