summaryrefslogtreecommitdiff
path: root/patterns/src
diff options
context:
space:
mode:
authorAdam Carpenter <53hornet@gmail.com>2019-03-15 15:40:00 -0400
committerAdam Carpenter <53hornet@gmail.com>2019-03-15 15:40:00 -0400
commit7daad878e8c34997d981a7afc37f59f373fccf29 (patch)
tree8bd5d74bac39ace52cdcaac65efdadb5a9ce1350 /patterns/src
parentfb82d9778bd3537988bd02dd944a2ae03a4855f3 (diff)
downloadlearning-rust-7daad878e8c34997d981a7afc37f59f373fccf29.tar.xz
learning-rust-7daad878e8c34997d981a7afc37f59f373fccf29.zip
Started first patterns exercise.
Diffstat (limited to 'patterns/src')
-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");
+ }
}