about summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2015-05-17 11:55:40 +0530
committerManish Goregaokar <manishsmail@gmail.com>2015-05-17 11:55:40 +0530
commit4e12a92d9bc30ea573421c61a98676b22d124e85 (patch)
tree04a7178179fcced5d4fde5212f6b6e7e8a49ab19 /src/libstd
parent1fd0a8455b19cac75a9cb910a0315493f13d2ee9 (diff)
parentb6e755df66eb5c54055ceef559ff985ddf78c446 (diff)
downloadrust-4e12a92d9bc30ea573421c61a98676b22d124e85.tar.gz
rust-4e12a92d9bc30ea573421c61a98676b22d124e85.zip
Rollup merge of #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 (a59de37e9).

It might be obvious, but I'm not well versed with rust, so feedback is very welcome.
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/fs.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libstd/fs.rs b/src/libstd/fs.rs
index fc5405ea7f6..481d9e69abd 100644
--- a/src/libstd/fs.rs
+++ b/src/libstd/fs.rs
@@ -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);
 ///             }
 ///         }
 ///     }