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:
parent
85bf07972a
commit
ee604fccd9
4 changed files with 100 additions and 0 deletions
|
|
@ -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() }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue