pub fn walk_files(dir : &Path, on_dir : &Fn(&Path) -> bool) -> Vec<PathBuf> {
	let mut files = Vec::new();

	// Read directory contents
	if let Ok(contents) = dir.read_dir() {
		for entry in contents.filter_map(|e| e.ok()) {
			// Store file
			if entry.path().is_file() {
				files.push(entry.path());
				continue;
			}

			// Recurse if wanted
			if on_dir(&entry.path()) {
				files.append(&mut walk_files(&entry.path(), on_dir));
			}
		}
	}

	return files;
}
/// Finds all files in a directory and its subdirectories, unless stopped
///
/// # Arguments
/// * `dir`    - The root directory
/// * `on_dir` - Function that is called for every directory found, should
///              return `true` if walking should continue into this directory
///              or `false` if not
Finds all files in a directory and its subdirectories, unless stopped
Finds all files in a directory and its subdirectories unless stopped
pub fn walk_files(dir : &Path, on_dir : &Fn(&Path) -> bool) -> Vec<PathBuf> {
	let mut files = Vec::new();
	// Read directory contents
	if let Ok(contents) = dir.read_dir() {
		for entry in contents.filter_map(|e| e.ok()) {
			// Store file
			if entry.path().is_file() {
				files.push(entry.path());
				continue;
			}
			// Recurse if wanted
			if on_dir(&entry.path()) {
				files.append(&mut walk_files(&entry.path(), on_dir));
			}
		}
	}
	return files;
}
pub fn walk_files ( dir : & Path , on_dir : & Fn ( & Path ) -> bool ) -> Vec < PathBuf > { let mut files = Vec :: new ( ) ; // Read directory contents if let Ok ( contents ) = dir . read_dir ( ) { for entry in contents . filter_map ( | e | e . ok ( ) ) { // Store file if entry . path ( ) . is_file ( ) { files . push ( entry . path ( ) ) ; continue ; } // Recurse if wanted if on_dir ( & entry . path ( ) ) { files . append ( & mut walk_files ( & entry . path ( ) , on_dir ) ) ; } } } return files ; }
Finds all files in a directory and its subdirectories, unless stopped
Finds all files in a directory and its subdirectories unless stopped
dir
&Path
on_dir
&Fn(&Path) -> bool