error break-value
What it means#
break value is allowed only in loop, which is an expression; for and while always produce () (§5.6).
Example#
fn main() {
for x in [1, 2, 3] {
break x // <- break-value
}
}error
break-value
How to fix#
fn firstOf(xs: List<i32>) -> i32 {
var found = 0
for x in xs {
found = x
break
}
found
}Use loop { ... break result }, or store the value in a variable and break without a value.