Skip to content

fs::walk_dir example without unstable features #25508

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 17, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions src/libstd/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1099,20 +1099,19 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
/// # Examples
///
/// ```
/// # #![feature(path_ext)]
/// use std::io;
/// use std::fs::{self, PathExt, DirEntry};
/// use std::fs::{self, DirEntry};
/// use std::path::Path;
///
/// // one possible implementation of fs::walk_dir only visiting files
/// fn visit_dirs(dir: &Path, cb: &mut FnMut(DirEntry)) -> io::Result<()> {
/// if dir.is_dir() {
/// fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> {
/// if try!(fs::metadata(dir)).is_dir() {
/// for entry in try!(fs::read_dir(dir)) {
/// let entry = try!(entry);
/// if entry.path().is_dir() {
/// if try!(fs::metadata(entry.path())).is_dir() {
/// try!(visit_dirs(&entry.path(), cb));
/// } else {
/// cb(entry);
/// cb(&entry);
/// }
/// }
/// }
Expand Down