BurntSushi / walkdir

Rust library for walking directories recursively.
The Unlicense
1.3k stars 109 forks source link

Allow end users to construct DirEntry #133

Closed MidasLamb closed 4 years ago

MidasLamb commented 4 years ago

Change pub(crate) to pub for the constructors, so end users can create DirEntries themselves.

I've got a project in which the filter_entry is a crucial part, it also depends on some input parameters. However, I can't write unit tests for the filter functionality, as I can't create DirEntries.

This PR allows the enduser to create DirEntries, in order to be able to construct unit tests for their filter function.

BurntSushi commented 4 years ago

I'm sorry, but these are specifically implementation details. They have changed over time and I do not feel comfortable giving up the flexibility.

You'll have to find some other way to test your code. Often the simplest is to just set up a real directory tree, which is what the tests for walkdir do. If that can't work, then you'll probably need to introduce some indirection in the form of a trait.

MidasLamb commented 4 years ago

Ok, thank's for the quick reply.

I will try to figure out another way of testing this.