1
0
Fork 0
mirror of https://github.com/azalea-rs/simdnbt.git synced 2025-08-02 07:26:04 +00:00

fix incorrect comment in mutf8.rs

This commit is contained in:
mat 2024-05-13 06:39:34 +00:00
parent d3176ee40e
commit 5289cf91b8

View file

@ -92,14 +92,14 @@ impl Mutf8Str {
#[inline]
pub fn from_str(s: &str) -> Cow<Mutf8Str> {
match mutf8::encode(s) {
Cow::Borrowed(b) => Cow::Borrowed(Mutf8Str::from_slice(b)),
Cow::Owned(o) => Cow::Owned(Mutf8String { vec: o }),
Cow::Borrowed(slice) => Cow::Borrowed(Mutf8Str::from_slice(slice)),
Cow::Owned(vec) => Cow::Owned(Mutf8String { vec }),
}
}
#[inline]
pub fn to_str(&self) -> Cow<str> {
// fast check to skip if none of the bytes have the top bit set or are null
// fast check to skip if none of the bytes have the top bit set
if is_plain_ascii(&self.slice) {
// SAFETY: &[u8] and &str are the same layout.
unsafe { Cow::Borrowed(std::str::from_utf8_unchecked(&self.slice)) }