Skip to content

Commit 4e12a92

Browse files
committed
Rollup merge of rust-lang#25508 - johshoff:visit_dirs_example, r=alexcrichton
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. Using rust 1.0.0 (a59de37). It might be obvious, but I'm not well versed with rust, so feedback is very welcome.
2 parents 1fd0a84 + b6e755d commit 4e12a92

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)