From 7daad878e8c34997d981a7afc37f59f373fccf29 Mon Sep 17 00:00:00 2001 From: Adam Carpenter <53hornet@gmail.com> Date: Fri, 15 Mar 2019 15:40:00 -0400 Subject: Started first patterns exercise. --- patterns/src/main.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) 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 = "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"); + } } -- cgit v1.2.3