added example of making directories and reading them in rust
parent
7af05460d7
commit
691be87cf6
@ -0,0 +1,2 @@
|
|||||||
|
/target
|
||||||
|
**/*.rs.bk
|
@ -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"
|
||||||
|
|
@ -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]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,38 @@
|
|||||||
|
use std::fs;
|
||||||
|
fn main()
|
||||||
|
{
|
||||||
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
|
||||||
|
match fs::create_dir("a")
|
||||||
|
{
|
||||||
|
Err(why) => 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());
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue