Hello, everyone! Just beginning to learn Rust and I've successfully run into my first roadblock (correct use of successfully? oh well..)
I have an example instanced struct, named args, of the original struct Args.
struct Args { arg1: bool, arg2: bool, }
and the instanced struct being:
let args = Args { arg1: true, arg2: false, }
Using these arguments, I am attempting to avoid a jumble of if-else statments and just use a match
statement. However, when attempting to perform the following:
match true { args.arg1 => println!("Argument 1 is true!"), args.arg2 => println!("Argument 2 is true!"), }
I am given the error
error: expected one of `=>`, `@`, `if`, or `|`, found `.` --> src/main.rs:13:13 | 13 | args.arg1 => println!("Argument one is true"), | ^ expected one of `=>`, `@`, `if`, or `|` here error: aborting due to previous error
Is there an escape character sequence I should use to avoid this, or is this simply incorrect syntax?
p.s. I threw this originally on stackoverflow, but, seeing as I am new to both places I figured I might as well go with the community dedicated to Rust itself..