Allow limited access to OsString bytes

This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString`
as suggested in feedback from `os_str_bytes` crate in #111544.
This commit is contained in:
Ed Page 2023-07-07 09:46:48 -05:00
parent 85bf07972a
commit ee604fccd9
4 changed files with 100 additions and 0 deletions

View file

@ -96,6 +96,16 @@ impl AsInner<[u8]> for Buf {
}
impl Buf {
#[inline]
pub fn into_os_str_bytes(self) -> Vec<u8> {
self.inner
}
#[inline]
pub unsafe fn from_os_str_bytes_unchecked(s: Vec<u8>) -> Self {
Self { inner: s }
}
pub fn from_string(s: String) -> Buf {
Buf { inner: s.into_bytes() }
}