From f311fc4dd136487dddcf647c36656478ef1372f1 Mon Sep 17 00:00:00 2001 From: Manuel Riquelme Date: Mon, 26 Jun 2023 11:46:57 +0200 Subject: [PATCH] iflet --- README.md | 1 + iflet/Cargo.toml | 8 ++++++++ iflet/src/main.rs | 14 ++++++++++++++ 3 files changed, 23 insertions(+) create mode 100644 iflet/Cargo.toml create mode 100644 iflet/src/main.rs diff --git a/README.md b/README.md index 4622a2d..4a3b452 100644 --- a/README.md +++ b/README.md @@ -30,3 +30,4 @@ - https://tinchicus.com/2022/07/14/rust-struct-en-multiples-archivos/ (estructura2) - https://tinchicus.com/2022/07/15/rust-tuple-struct/ (nuevotipo) - https://tinchicus.com/2022/07/18/rust-enum/ (enums) +- https://tinchicus.com/2022/07/19/rust-patrones-y-coincidencias/ (iflet) diff --git a/iflet/Cargo.toml b/iflet/Cargo.toml new file mode 100644 index 0000000..05c061f --- /dev/null +++ b/iflet/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "iflet" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/iflet/src/main.rs b/iflet/src/main.rs new file mode 100644 index 0000000..d898d9a --- /dev/null +++ b/iflet/src/main.rs @@ -0,0 +1,14 @@ +fn main() { + let x = 1; + + match x { + 1 => println!("uno"), + _ => println!("no encontrado"), + } + + if let 1 = x { + println!("uno") + } else { + println!("no encontrado") + } +}