stable-osstring-encoding 2.1.0

Converts OsString (and more) to and from raw data with an encoding that will not change based on the compiler version.
Documentation
use crate::{EncodingWidth, FromRawStableEncoding, IntoRawStableEncoding, ToRawStableEncoding};
use std::{
	borrow::Cow,
	ffi::{OsStr, OsString},
};

#[cfg(unix)]
use std::os::unix::ffi::{OsStrExt, OsStringExt};
#[cfg(target_os = "wasi")]
use std::os::wasi::ffi::{OsStrExt, OsStringExt}; // this is just a re-export of the unix version



impl ToRawStableEncoding for OsStr {
	#[inline]
	fn to_raw_stable_encoding(&self) -> Vec<EncodingWidth> {
		self.as_bytes().to_vec()
	}
}

impl IntoRawStableEncoding for OsString {
	#[inline]
	fn into_raw_stable_encoding(self) -> Vec<EncodingWidth> {
		self.into_vec()
	}
}

impl FromRawStableEncoding for OsString {
	#[inline]
	unsafe fn from_raw_stable_encoding<'a>(encoded: impl Into<Cow<'a, [EncodingWidth]>>) -> Self {
		Self::from_vec(encoded.into().into_owned())
	}
}