Skip to content

Commit b6e755d

Browse files
committed
fs::walk_dir example without unstable features
The current version of the example won't compile due to unstable features. This is an attempt to fix that, at the cost of slightly more verbose code.
1 parent 0d707d1 commit b6e755d

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/libstd/fs.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -1099,20 +1099,19 @@ pub fn remove_dir_all<P: AsRef<Path>>(path: P) -> io::Result<()> {
10991099
/// # Examples
11001100
///
11011101
/// ```
1102-
/// # #![feature(path_ext)]
11031102
/// use std::io;
1104-
/// use std::fs::{self, PathExt, DirEntry};
1103+
/// use std::fs::{self, DirEntry};
11051104
/// use std::path::Path;
11061105
///
11071106
/// // one possible implementation of fs::walk_dir only visiting files
1108-
/// fn visit_dirs(dir: &Path, cb: &mut FnMut(DirEntry)) -> io::Result<()> {
1109-
/// if dir.is_dir() {
1107+
/// fn visit_dirs(dir: &Path, cb: &Fn(&DirEntry)) -> io::Result<()> {
1108+
/// if try!(fs::metadata(dir)).is_dir() {
11101109
/// for entry in try!(fs::read_dir(dir)) {
11111110
/// let entry = try!(entry);
1112-
/// if entry.path().is_dir() {
1111+
/// if try!(fs::metadata(entry.path())).is_dir() {
11131112
/// try!(visit_dirs(&entry.path(), cb));
11141113
/// } else {
1115-
/// cb(entry);
1114+
/// cb(&entry);
11161115
/// }
11171116
/// }
11181117
/// }

0 commit comments

Comments
 (0)