summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--patterns/src/main.rs22
1 files changed, 21 insertions, 1 deletions
diff --git a/patterns/src/main.rs b/patterns/src/main.rs
index e7a11a9..c4d9d65 100644
--- a/patterns/src/main.rs
+++ b/patterns/src/main.rs
@@ -1,3 +1,23 @@
fn main() {
- println!("Hello, world!");
+ let favorite_color: Option<&str> = None;
+ let is_tuesday = false;
+ let age: Result<u8, _> = "34".parse();
+
+ if let Some(color) = favorite_color {
+ dbg!(color);
+ }
+ else if is_tuesday {
+ dbg!("green");
+ }
+ else if let Ok(age) = age {
+ if age > 30 {
+ dbg!("purple");
+ }
+ else {
+ dbg!("orange");
+ }
+ }
+ else {
+ dbg!("blue");
+ }
}