-
Notifications
You must be signed in to change notification settings - Fork 479
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
Adding some path functions #872
Conversation
Awesome, thanks for tackling this! I probably won't be able to take a look at this today, but I should have time tomorrow. In the meantime, it looks like there are some errors from clippy on CI. |
Managed it, thanks! |
Just took a quick look, and overall I think it looks good. You're running into a lot of the things that make Rust painful, for example, the fact that paths might not be valid Unicode. I think one thing that might make this a whole lot nicer is if you use camino's The other thing that would be nice would be to de-deuplicate these format calls:
I'm not entirely sure what the best way to do this would be, but you could do something like:
If the path is set in backticks, then I think:
Is a good error message. |
Actually, you could skip the function and just put |
Also, thanks for adding tests! That's something that a lot of people forget to do. |
My pleasure. I reimplemented the functions using camino and simplifying the error handling. I'm totally not sure about dependency management. Am I supposed to commit the Cargo.lock file too? |
And btw compliments for the functions "interface", adding functionality (even coming from a totally different language like Scala) was pretty trivial since it is really well designed ;) |
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.
Looking better! A few more comments.
As for the lock file, yes, that should be committed. The general rule is that for binary crates, such as just
, the lockfile should be committed so that builds are reproducible. For library crates, the lockfile shouldn't be committed, since it's up to the binary crate that the library is eventually included in to determine dependency versions to use.
Thank you! It's actually pretty easy to add functions that introduce new functionality, so I kind of wonder why I haven't added more over the years. |
Not sure if you saw, but I added some comments in-line, for example. |
Yes, I read the previous comment from the phone, and it hid the in-line comments. I think I addressed them all now. |
Looks great! How about using consistent language in all the error message, so:
Also, instead of:
How about:
|
Typo, my bad. Is this okay? |
I just added some suggestions, I think you can just click a button to apply them to the branch. I realized that all the error messages are in the past tense, so I switched to |
I'm not sure to see where you wrote them, I've closed the discussion for all the previous comments but the one I linked (since I'm not sure about how to add the import in
I'll apply these changes asap. |
Ahhh, damn, sorry, I forgot to hit the "submit review" button, so you couldn't see any of them. |
Co-authored-by: Casey Rodarmor <[email protected]>
Just applied everything and verified locally that both tests and clippy are good |
Great, looks good, although I think there's a formatting issue. |
Merged! |
I've tried to add the functions I talked about in #871, mirroring the standard library functions from
Path
.I've added a bunch of tests, but I haven't updated the documentation.
I'm looking forward to getting this pull request reviewed because it will be my first rust contribution if it gets merged.
For the very same reason, it could be non-optimal or straightforward.
Closes #871.