-
-
Save vcsjones/510719f51816cc7570b8c251449fc0b7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::fs::read_dir; | |
fn main() { | |
match print_paths("special") { | |
Ok(()) => println!("Done"), | |
Err(a) => println!("Errors happened: {}", a) | |
} | |
} | |
fn print_paths(path : &str) -> Result<(), std::io::Error> { | |
let paths = read_dir(path)?; | |
for path in paths { | |
let path_buf = path?.path(); | |
if let Some(name) = path_buf.to_str() { | |
println!("Name: {}", name); | |
} else { | |
println!("Closest name: {}", path_buf.to_string_lossy()) | |
} | |
} | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment