Hi, help me to understand String and &str. Reading directory. i try with this piece:
use std::{fs, io};
fn main() {
// reading video folder
println!("Get video folder:");
let mut video_folder = String::new();
let stdin = io::stdin();
stdin.read_line(&mut video_folder);
println!("Video folder is: {} ", video_folder);
// read files in dir
//let temp: &str = "/home/pichibw/"; // this variable work fine !!!
for file in fs::read_dir(video_folder).unwrap() {
println!("{}", file.unwrap().path().display());
}
}
OUTPUT ERROR:
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: Os { code: 2, kind: NotFound, message: "No such f
ile or directory" }', src/main.rs:45:36
note: run with RUST_BACKTRACE=1
environment variable to display a backtrace