#001 Jan 5, 2022macro match1. 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.Or1 2 3 let bar = Some(4); assert!(matches!(bar, Some(x) if x > 2)); This post is licensed under CC BY 4.0 by the author.Share: ← Previous 0. Hello, rustbites! Next → 2. mysterious @