camino-rs / camino

Like Rust's std::path::Path, but UTF-8.

Home Page:https://docs.rs/camino

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

read_dir() throws me back into std::path::Path

gralpli opened this issue · comments

let path = Utf8Path::new("/some/path");

for entry in path.read_dir()? {
    let entry = entry?;

    let this_returns_an_OsString = entry.file_name(); // should be String
    let this_returns_a_PathBuf = entry.path(); // should be Utf8Path
}
commented

Thanks for the report! Camino's behavior is correct: a utf8 directory path might contain a non-utf8 file name.

I'm happy to consider suggestions like adding a read_dir_utf8 though.

I'd love something like read_dir_utf8 since when I use Camino I know that all paths will be UTF8 (and if any is not then it's considered to be an error).

commented

This is out as part of Camino 1.0.8 @gralpli @malaire