Skip to content

fs-err: Use AsRef<Path> to match std::fs#76

Open
thughes wants to merge 1 commit intoandrewhickman:mainfrom
thughes:as-ref
Open

fs-err: Use AsRef<Path> to match std::fs#76
thughes wants to merge 1 commit intoandrewhickman:mainfrom
thughes:as-ref

Conversation

@thughes
Copy link
Copy Markdown

@thughes thughes commented Sep 22, 2025

In order for fs-err to be a drop-in replacement for std::fs, it needs to match the std::fs signature exactly.

Note that this can result in an extra allocation when the path provided is already a PathBuf, but keeping the same API as std::fs is better than over-optimizing for that case.

Fixes #34.

@thughes thughes marked this pull request as draft September 22, 2025 23:15
In order for fs-err to be a drop-in replacement for std::fs, it
needs to match the std::fs signature exactly.

Note that this can result in an extra allocation when the path provided
is already a PathBuf, but keeping the same API as std::fs is better than
over-optimizing for that case.

Fixes andrewhickman#34.
@thughes thughes marked this pull request as ready for review September 22, 2025 23:57
@cyqsimon
Copy link
Copy Markdown

I was intending to submit a similar PR but fortunately saw this in time.

First of all, my disposition towards this change is positive. I think it brings this library closer to advertised. However I do think this is technically a breaking change, because T: Into<PathBuf> may not always satisfy T: AsRef<Path>.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

path type different than std::fs::File

2 participants