← Back to context

Comment by adastra22

2 days ago

I'd agree if it was &[bytes] or whatever. But &[u8] isn't that much different from &str.

Isn't &[u8] what you should be using for command-line arguments and filenames and whatnot? In that case you'd want its name to be short, like &[u8], rather than long like &[bytes] or &[raw_uncut_byte] or something.

  • OsStr/OsString is what you would use in those circumstances. Path/PathBuf specifically for filenames or paths, which I think uses OsStr/OsString internally. I've never looked at OsStr's internals but I wouldn't be surprised if it is a wrapper around &[u8].

    Note that &[u8] would allow things like null bytes, and maybe other edge cases.