BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.3k stars 109 forks source link

example not working #161

Closed masta99wrfvsHsa closed 2 years ago

masta99wrfvsHsa commented 2 years ago

below is my code>

use walkdir::WalkDir;

fn main() { println!("Hello, world!"); use std::io::{stdin,stdout,Write}; let mut s=String::new(); print!("Please enter some text: "); let _=stdout().flush(); stdin().read_line(&mut s).expect("Did not enter a correct string"); if let Some('\n')=s.chars().next_back() { s.pop(); } if let Some('\r')=s.chars().next_back() { s.pop(); } println!("You typed:{}",s);

/*refer,https://github.com/BurntSushi/walkdir*/
for entry in WalkDir::new(s).into_iter().filter_map(|e| e.ok()) {
println!("{}", entry.path().display());
}

/*
for entry in WalkDir::new(&s) {
let entry = entry.unwrap();
println!("{}", entry.path().display());
}
*/

}

my command log> D:\Coding\rust\gnuwin\walkfolders>cargo build Compiling walkfolders v0.1.0 (D:\Coding\rust\gnuwin\walkfolders) Finished dev [unoptimized + debuginfo] target(s) in 13.11s

D:\Coding\rust\gnuwin\walkfolders>cd src

D:\Coding\rust\gnuwin\walkfolders\src>main Hello, world! Please enter some text: D:\Coding\rust\gnuwin You typed: D:\Coding\rust\gnuwin

D:\Coding\rust\gnuwin\walkfolders\src>

(By right it should print src and git directory right?)

BurntSushi commented 2 years ago

Please format your code using backticks with invention. It's an unreadable mess right now. And please provide a minimal program. There shouldn't need to be anything about reading from stdin to reproduce the problem.

masta99wrfvsHsa commented 2 years ago

sorry it actually worked.i final binary is in target folder.i used the wrong binary.