I am trying to compare a given input to a function against several fields of a struct
struct Bla {
bla1: u32,
bla2: u32,
}
impl Bla {
fn new() -> Self {
Self {
bla1: 5,
bla2: 6,
}
}
fn check(&self, b: u32) -> bool {
match b {
self.bla1 => true,
self.bla2 => true,
_ => false
}
}
}
fn main() {
let bli: Bla = Bla::new();
println!("{}", bli.check(5));
}
However, I get a compile error
Compiling playground v0.0.1 (/playground)
error: expected one of `!`, `(`, `...`, `..=`, `..`, `::`, `=>`, `if`, `{`, or `|`, found `.`
--> src/main.rs:16:17
|
16 | self.bla1 => true,
| ^ expected one of 10 possible tokens
error: could not compile `playground` due to previous error
Why can't I perform the match I tried to do?