File::open winds up copying the path it’s given. I understand why the current implementation does so, but I wonder if there’s a way to avoid it through the
open(2) and using
FromRawFd::from_raw_fd, I mean, which is what I’m currently doing.)
More specifically: The way that
CString are specified makes me wonder if the current method could even be reimplemented to avoid allocating. Thoughts?
(I’m very allocation-conscious from my day job, since every allocation is a potential failure to consider.
open(2) can fail for several reasons, but userland heap exhaustion is not among them, and it certainly won’t kill the caller if the pointers are valid – so I was surprised to see the additional risk in Rust.)