maciejhirsz / beef

Faster, more compact implementation of std::borrow::Cow
https://crates.io/crates/beef
Apache License 2.0
338 stars 17 forks source link

Support for `Path`/`PathBuf` #30

Open Alxandr opened 4 years ago

Alxandr commented 4 years ago

As far as I can see, I'm not able to put own/std types into a beefcow except those that are explicitly enabled in this library. So would it be possible to add support for Path/PathBuf?

maciejhirsz commented 4 years ago

Sadly neither PathBuf or OsString exposes *_raw_parts methods, or any way to get a byte pointer or some such, so this has to sit on the backburner until std is extended.

Alxandr commented 4 years ago

Yeah. I looked at implementing it myself the other day and ran into the same issue. Was hoping that more eyes on the issue might figure out something clever :P. Maybe if there exists some other type than PathBuf that is AsRef<Path> that does allow getting parts?

maciejhirsz commented 4 years ago

The only such type that can correctly map it is OsStr/OsSTring. The os_str_bytes crate might be of some use here, will have to dig in further.