From 61e19478bd5b11f4a0b1706f561e0ddad1eaab1b Mon Sep 17 00:00:00 2001 From: Manuel Riquelme Date: Fri, 9 Jun 2023 12:54:08 +0200 Subject: [PATCH] while --- README.md | 1 + whileloop/Cargo.toml | 8 ++++++++ whileloop/src/main.rs | 9 +++++++++ 3 files changed, 18 insertions(+) create mode 100644 whileloop/Cargo.toml create mode 100644 whileloop/src/main.rs diff --git a/README.md b/README.md index 5c6f992..ff29ee0 100644 --- a/README.md +++ b/README.md @@ -22,3 +22,4 @@ - https://tinchicus.com/2022/06/29/rust-el-parametro-_/ (bucles2) - https://tinchicus.com/2022/06/30/rust-loop-27/ (arreglos2) - https://tinchicus.com/2022/07/01/rust-loop-labels/ (nombre) +- https://tinchicus.com/2022/07/04/rust-while/ (whileloop) diff --git a/whileloop/Cargo.toml b/whileloop/Cargo.toml new file mode 100644 index 0000000..713d13a --- /dev/null +++ b/whileloop/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "whileloop" +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/whileloop/src/main.rs b/whileloop/src/main.rs new file mode 100644 index 0000000..1e24967 --- /dev/null +++ b/whileloop/src/main.rs @@ -0,0 +1,9 @@ +fn main() { + let mi_arreglo = ["Lovecraft", "Poe", "Barker", "King"]; + let mut i = 0; + + while i < mi_arreglo.len() { + println!("{}", mi_arreglo[i]); + i = i + 1; + } +}