elast0ny / shared_memory

A Rust wrapper around native shared memory for Linux and Windows
382 stars 51 forks source link

Uses references to String/PathBuf instead of str/Path in constructors #15

Closed sdroege closed 5 years ago

sdroege commented 6 years ago

At least SharedMemRaw::create(), ::open() internally just takes a reference of the string, so could use a &str instead (to allow no allocations).

Similarly SharedMemConf::set_link_path() takes &PathBuf and that could just be a &Path for the same reason, and the same in SharedMem::create_linked() and SharedMem::open_linked().

Relatedly, get_link_path() and get_os_path() and similar should probably return references to the unowned types (str, Path) instead.


And it seems that the OS path related API should actually use OsStr / OsString instead, AFAIU it might not be a valid UTF8 string (on UNIX systems at least).

elast0ny commented 5 years ago

Better late than never ! Thanks :+1: