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

Contents first order issue #140

Open
silasb opened this issue Sep 12, 2020 · 2 comments
Open

Contents first order issue #140

silasb opened this issue Sep 12, 2020 · 2 comments

Comments

@silasb
Copy link

silasb commented Sep 12, 2020

I have a folder structure like

$ find test/
test/
test/1.py
test/2a
test/2a/2.py
test/2a/2a.py
test/1a.py
test/2
test/2/2.py
test/2/2a.py
test/2/3
test/2/3/3.py

Doing

    for entry in WalkDir::new(t.input).contents_first(true) {
        let entry = entry.unwrap();
        println!("{}", entry.path().display());
   }

results in

test/1.py
test/2a/2.py
test/2a/2a.py
test/2a
test/1a.py
test/2/2.py
test/2/2a.py
test/2/3/3.py
test/2/3
test/2
test/

I'd expect to see

test/2/3/3.py
test/2/3
test/2a/2.py
test/2a/2a.py
test/2a
test/2/2.py
test/2/2a.py
test/2
test/1.py
test/1a.py
test/

per what the documentation is suggesting.

@BurntSushi
Copy link
Owner

The behavior is correct. The docs could be improved, probably with a better example. contents_first just changes when the entry for the directory itself is returned. It doesn't cause traversal to visit the deepest nodes first.

@silasb
Copy link
Author

silasb commented Sep 14, 2020

Thanks, that makes sense. I ended up solving my problem a different way. Do you want me to close this ticket?

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

No branches or pull requests

2 participants