#How would I match fields in self?
1 messages · Page 1 of 1 (latest)
Match patterns can't be dynamic. You could use match guards (embedded if statements in the patterns) which may make it easier to read than a if else chain
1 messages · Page 1 of 1 (latest)
I have a value that I need to match, that i'm currently using if else statements for and I was wondering if there's a way using match, i.e. something like this (which doesn't compile):
let id = 12;
match id {
self.A.x.id => (),
self.A.y.id => (),
self.B.x.id => (),
self.B.y.id => (),
}
Match patterns can't be dynamic. You could use match guards (embedded if statements in the patterns) which may make it easier to read than a if else chain