E0114
Payload labels mixed
ErrorA variant's payload labels every field or none: Move(x: i64, y: i64) or Move(i64, i64), not Move(i64, y: i64). The error points at the first field labeled differently from the first field.
Why
A labeled variant is built with every label, in order, as a class is; an unlabeled one is built by position. A payload with some labels would need both rules at once. The labels need names only you can choose, so there is no fix.
Broken
enum Step {
Move(i64, to: i64)
}
fn main() {
print(1)
}
What sisu says
error[E0114]: label every field of `Move` or none --> E0114.sisu:2:15 | 2 | Move(i64, to: i64) | ^^ sisu: 1 error sisu: for more on a code, run `sisu explain <code>`: E0114
Fixed
enum Step {
Move(from: i64, to: i64)
}
fn main() {
let s = Step.Move(from: 1, to: 2)
match s {
Move(from, to) => print(to - from)
}
}
Sisu