#001 Jan 2022

1. matches!

Need to check if an expression matches certain pattern?

1
2
let foo = vec!['1','2'];
assert!(matches!(foo.len(), 0..=1));

The example above checks if len is 0 or 1.

Or

1
2
3
let bar = Some(4);

assert!(matches!(bar, Some(x) if x > 2));
#000 Jan 2022

0. Hello, rustbites!

Hello and welcome to rustbites.com

1
2
let hello = "Hello, rustbites!";
println!("{}", hello);

explanation and details