Skip to content
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

io::walk_dir could have a more detailed return value, to avoid extra stat calls #16236

Closed
huonw opened this issue Aug 4, 2014 · 4 comments
Closed

Comments

@huonw
Copy link
Member

huonw commented Aug 4, 2014

When calling walk_dir one often wishes to handle files and directories differently, the walk_dir call knows this internally (it calls .is_dir and readdir etc.) but this is not passed on to the users, and so users are forced to call .is_dir etc. themselves.

Maybe walk_dir could return a Iterator<DirEntry>, with (as a bikeshedable suggestion)

struct DirEntry {
    pub path: Path,
    pub stat: FileStat
}

(Inspired by http://legacy.python.org/dev/peps/pep-0471/ , which shows dramatic performance improvements with changes similar to this.)

@huonw
Copy link
Member Author

huonw commented Aug 4, 2014

cc #16237

cc @alexcrichton

@alexcrichton
Copy link
Member

Interesting! We should definitely keep this in mind when stabilizing the walk_dir function. It sounds like this would be great to implement.

@aturon
Copy link
Member

aturon commented Aug 4, 2014

cc me

@alexcrichton
Copy link
Member

This is now implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants