Michael-F-Bryan / include_dir

The logical evolution of the include_str macro for embedding a directory tree into your binary.
https://michael-f-bryan.github.io/include_dir
MIT License
319 stars 36 forks source link

Support getting files etc. in `const` #76

Closed ModProg closed 2 years ago

ModProg commented 2 years ago

Not sure if this is achievable witht the current architecture, but I would like to be able to query files in const. Hopefully this gets done in the need future so I could then also unwrap the resulting file: https://github.com/rust-lang/rust/issues/67441.

Michael-F-Bryan commented 2 years ago

The Dir::entries() getter is const, so you should already be able to look up files at compile time.

You'd need to write your own recursive search function though. I don't think the existing methods for looking up items (e.g. Dir::get_file()) can be made const because they take some S: AsRef<Path> and traits aren't allowed in const contexts yet.

ModProg commented 2 years ago

Alright, makes sense.