New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use AsRef<Path> instead of &str. #80
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @npatsakula for this PR.
I would be in favor of actually moving from &str
to Path
instead of AsRef<Path>
for 2 reasons:
- As you mention, not every filesystem path is a valid utf-8 string. If we decide to take the path of correctness, it makes sense to expect a
Path
. The user can still convert the&str
it may use toPath
before passing it to the tokenizers and vocabs. - Using
Option
with generics withAsRef
leads to awkwardNone
arguments, requiring the user to passNone::<Path>
instead of simplyNone
. I feel this is a high price to pay for allowing (possibly incorrects)&str
as path representation.
What do you think? The next few pull requests will introduce breaking changes anyway, so I think using Path
makes sense here.
I believe this would be ready to merge before #79 (I am not fully bought in the idea of snafu
) so it may make sense to merge this one first and revert the error handling commits on this branch.
5743299
to
bb90683
Compare
Now I replaced all |
Hello @npatsakula , You are right I got confused into assuming that I apologize - but you convinced me that your original choice was, indeed, the right one. I would be happy to go with I'm happy to help our revert the changes if you'd like me to do so, please let me know. |
This reverts commit 96f80a2.
Hello @guillaume-be! I reverted to |
Thanks a lot! looks good to merge - sorry again for the unneeded iterations |
Master PR: #76
Blocked by: #79
Motivation
AsRef<Path>
is strictly more acceptable with same level of correctness:you can use
&str
,Path
andPathBuf
.Implementation
AsRef<Path>
instead of&str
.@veta666, this one is also on you.