// Created on savesnippets.com ยท https://savesnippets.com/ayKMtl6vv8ntEw fn classify(n: i32) -> &'static str { match n { 0 => "zero", 1..=9 => "single digit", 10..=99 => "double digit", n if n < 0 => "negative", n if n % 2 == 0 => "even big number", _ => "odd big number", } } fn describe(opt: Option) -> String { match opt { Some(x @ 1..=10) => format!("small Some: {x}"), Some(x) if x > 100 => format!("big Some: {x}"), Some(x) => format!("normal Some: {x}"), None => "nothing".into(), } } fn main() { for n in [-3, 0, 7, 42, 105, 200] { println!("{n}: {}", classify(n)); } println!("{}", describe(Some(5))); // small Some: 5 println!("{}", describe(Some(500))); // big Some: 500 }