path type different than std::fs::File
std::fs::File uses AsRef<Path> as the type for passing paths while fs_err uses Into<PathBuf>
This makes fs_err not be a "drop in replacement": When I pass an AsRef<Path> to fs_err::File::open, it does not compile
This is true. Maybe we should qualify this statement with an asterisk and explain how we differ?
Alternatively, maybe we should change our bounds to either P: AsRef<Path> or P: AsRef<Path> + Into<PathBuf>. The latter would let us avoid an allocation but doesn't really solve this issue.
I also hit this, and had to rework some code. I'm guessing the error types need to own the path and that's why this is done?
Is it really necessary that the error should own the path? Can't it just store the reference to the path instead?
@TonalidadeHidrica The error must own the path, it cannot be a reference because that would make both the wrapper and the error non-'static. Requiring Into<PathBuf> rather than AsRef<Path> is basically an optimization, allowing fs_err to avoid an allocation when you pass an actual PathBuf.
This issue should probably be resolved by a PR that improves the docs to explain this, and show how to change the code that doesn't compile due to the difference. (The change is trivial, but can be perplexing to a newbie.)
Its worth noting that all uses of Into<PathBuf> are for constructing an fs_err::File, which owns a PathBuf even in the happy path. All the other functions were changed to AsRef<Path> in #31 and will allocate only in the failure path.
I'd be happy to accept a PR to improve docs around this