use super::prelude::*;
#[derive(PartialEq, Eq, PartialOrd, Ord)]
#[repr(transparent)]
pub struct Mutf8Str {
inner: [u8],
}
impl Mutf8Str {
impl_str_encoding_meths!(base, Mutf8Str, any, "MUTF-8");
impl_str_encoding_meths!(str, Mutf8Str, any, "MUTF-8");
}
impl Mutf8Str {
pub const ENCODE_NUL: bool = true;
pub const NUL_TERM: bool = false;
pub(crate) const unsafe fn _from_bytes_unchecked(bytes: &[u8]) -> &Self {
&*(bytes as *const [u8] as *const Self)
}
pub(crate) const fn _raw_bytes(&self) -> &[u8] {
unsafe { &*(self as *const Self as *const [u8]) }
}
}
impl ToOwned for Mutf8Str {
type Owned = Mutf8String;
fn to_owned(&self) -> Self::Owned {
unsafe { Self::Owned::from_bytes_unchecked(self.inner.to_vec()) }
}
}
impl Default for &Mutf8Str {
fn default() -> Self {
const EMPTY: &[u8] = &[];
unsafe { Mutf8Str::from_bytes_unchecked(EMPTY) }
}
}