From 691be87cf6153d0d75c9664da74e687f62852b8a Mon Sep 17 00:00:00 2001 From: Penguin Date: Thu, 2 Jul 2020 13:09:11 -0500 Subject: [PATCH] added example of making directories and reading them in rust --- testing_rust_again/.gitignore | 2 ++ testing_rust_again/Cargo.lock | 6 ++++++ testing_rust_again/Cargo.toml | 9 ++++++++ testing_rust_again/GPATH | Bin 0 -> 16384 bytes testing_rust_again/GRTAGS | Bin 0 -> 16384 bytes testing_rust_again/GTAGS | Bin 0 -> 16384 bytes testing_rust_again/src/main.rs | 38 +++++++++++++++++++++++++++++++++ 7 files changed, 55 insertions(+) create mode 100644 testing_rust_again/.gitignore create mode 100644 testing_rust_again/Cargo.lock create mode 100644 testing_rust_again/Cargo.toml create mode 100644 testing_rust_again/GPATH create mode 100644 testing_rust_again/GRTAGS create mode 100644 testing_rust_again/GTAGS create mode 100644 testing_rust_again/src/main.rs diff --git a/testing_rust_again/.gitignore b/testing_rust_again/.gitignore new file mode 100644 index 0000000..53eaa21 --- /dev/null +++ b/testing_rust_again/.gitignore @@ -0,0 +1,2 @@ +/target +**/*.rs.bk diff --git a/testing_rust_again/Cargo.lock b/testing_rust_again/Cargo.lock new file mode 100644 index 0000000..1c89607 --- /dev/null +++ b/testing_rust_again/Cargo.lock @@ -0,0 +1,6 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "testing_rust_again" +version = "0.1.0" + diff --git a/testing_rust_again/Cargo.toml b/testing_rust_again/Cargo.toml new file mode 100644 index 0000000..3811bac --- /dev/null +++ b/testing_rust_again/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "testing_rust_again" +version = "0.1.0" +authors = ["Penguin <...>"] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/testing_rust_again/GPATH b/testing_rust_again/GPATH new file mode 100644 index 0000000000000000000000000000000000000000..d1b3b58cd107d400dc80c4fddc93a05d575cb283 GIT binary patch literal 16384 zcmeI%O-_SA6bJC}Yvp|qu@3lr0YF{wtIrmhIkk&sd_42^mNkKh4%5D(HL zcnD``u%zNb<3{r*p-gyvZ{GWLcJ=5U*&*W6YaEH(k8l*xoN;MW5T?7U}TJEVH`N=oM(<3xM5uP7;9UW z$y}FqD6^?PA&E$BiF;Sp_)&#+UPJaamNi7m1!Fvq*->!8)%LG4q(5KhL8d fc?JLHygWklJb6B4Kl%9_^{;QvF9+qdW)kua5|qG- literal 0 HcmV?d00001 diff --git a/testing_rust_again/GRTAGS b/testing_rust_again/GRTAGS new file mode 100644 index 0000000000000000000000000000000000000000..604f14859207312a22ef3258bbaf254aa0b9a9e2 GIT binary patch literal 16384 zcmeIu!3n}J6b9g^cvB}3(g_4F-ivrB*j7}$3Qo{r9L8ZB#-sv&;(A?O vcE?lIHp5(OLYSv^p8fu|tq)CE@4k!QGyAIfoau{@-^%lSwcMV+a%#N*SSKGs literal 0 HcmV?d00001 diff --git a/testing_rust_again/GTAGS b/testing_rust_again/GTAGS new file mode 100644 index 0000000000000000000000000000000000000000..7a6cfa30866d97f80c94870107aa9b6b8d5085c6 GIT binary patch literal 16384 zcmeIuJqp4=5C+gyu~QFVVfF-qjlD<;3x6 println!("! {:?}", why.kind()), + Ok(_) => {}, + } + + println!("We just made a new directory! Printing...\n"); + match fs::read_dir(".") + { + Err(why) => println!("! {:?}", why.kind()), + Ok(paths) => for path in paths + { + println!("> {:?}", path.unwrap().path()); + }, + } + + fs::remove_dir("a").unwrap_or_else(|why| { + println!("! {:?}", why.kind()); + }); + + + println!("We just removed that directory! Printing...\n"); + match fs::read_dir(".") + { + Err(why) => println!("! {:?}", why.kind()), + Ok(paths) => for path in paths + { + println!("> {:?}", path.unwrap().path()); + }, + } + +}