Here's a version rewritten to return (opaque) errors and to use Path
and PathBuf
instead of String
s. Feel free to take what you like, no credit needed.
Some specific notes:
- I didn't see any reason for this to be
async
- You almost always want to take a
&str
instead of a&String
- But here you want a
&Path
- Or the generic version I used, which is less typing for users of the function, at the cost of more monomorphizing. Many libraries, including std, use this convention
- But here you want a
- Even if you're only ever going to
unwrap
returned errors, you can see how much the ability to use?
can clean up your code- You could always have a wrapper that
unwrap
s if it's a bother
- You could always have a wrapper that