This is a flawed implementation of the Abomonation trait for the PathBuf type from the standard library. I'd love some feedback on whether you'd be open to merge an improved implementation (some thoughts below).
The motivation for this: I'm trying out differential-dataflow (amazing library!) for a code analysis tool and have a bunch of filesystem paths that I'd like to send through a dataflow graph.
The flaw in the implementation in this PR (that I'm aware of, there might be others): it uses a unix-specific function and so will cause compilation failures on non-unix platforms. Some options I see:
Use a macro to only add the instance on Unix platforms
Use OsStr::to_str to get a &str, then call as_bytes() on that. This path should work on all platforms, but has two downsides I'm aware of:
OsStr::to_str fails when the path contains non-unicode characters, so we'd have that new error case.
OsStr::to_str performs a unicode check, so it's not as fast.
Would this PR be acceptable with one of the changes above? I can also imagine there's entirely different problems that I'm not aware of!
This is a flawed implementation of the
Abomonation
trait for thePathBuf
type from the standard library. I'd love some feedback on whether you'd be open to merge an improved implementation (some thoughts below).The motivation for this: I'm trying out differential-dataflow (amazing library!) for a code analysis tool and have a bunch of filesystem paths that I'd like to send through a dataflow graph.
The flaw in the implementation in this PR (that I'm aware of, there might be others): it uses a unix-specific function and so will cause compilation failures on non-unix platforms. Some options I see:
OsStr::to_str
to get a&str
, then callas_bytes()
on that. This path should work on all platforms, but has two downsides I'm aware of:OsStr::to_str
fails when the path contains non-unicode characters, so we'd have that new error case.OsStr::to_str
performs a unicode check, so it's not as fast.Would this PR be acceptable with one of the changes above? I can also imagine there's entirely different problems that I'm not aware of!