pub struct Wtf8Atom(/* private fields */);Expand description
Clone-on-write WTF-8 string.
See [tendril] for more details.
Implementations§
Source§impl Wtf8Atom
impl Wtf8Atom
pub fn as_wtf8(&self) -> &Wtf8
pub fn as_atom(&self) -> Option<&Atom>
Sourcepub fn to_atom_lossy(&self) -> Cow<'_, Atom>
pub fn to_atom_lossy(&self) -> Cow<'_, Atom>
Returns the UTF-8 Atom representation, borrowing when possible.
Sourcepub fn try_into_atom(self) -> Result<Atom, Wtf8Atom>
pub fn try_into_atom(self) -> Result<Atom, Wtf8Atom>
Sourcepub unsafe fn from_bytes_unchecked(bytes: &[u8]) -> Self
pub unsafe fn from_bytes_unchecked(bytes: &[u8]) -> Self
Creates a new Wtf8Atom from a byte slice.
§Safety
The caller must ensure that bytes is a well-formed WTF-8 byte
sequence.
See hstr::wtf8::Wtf8::from_bytes_unchecked for more details.
Methods from Deref<Target = Wtf8>§
pub fn slice(&self, begin: usize, end: usize) -> &Wtf8
pub fn slice(&self, begin: usize, end: usize) -> &Wtf8
Return a slice of the given string for the byte range [begin..end).
§Failure
Fails when begin and end do not point to code point boundaries,
or point beyond the end of the string.
pub fn slice_from(&self, begin: usize) -> &Wtf8
pub fn slice_from(&self, begin: usize) -> &Wtf8
Return a slice of the given string from byte begin to its end.
§Failure
Fails when begin is not at a code point boundary,
or is beyond the end of the string.
pub fn slice_to(&self, end: usize) -> &Wtf8
pub fn slice_to(&self, end: usize) -> &Wtf8
Return a slice of the given string from its beginning to byte end.
§Failure
Fails when end is not at a code point boundary,
or is beyond the end of the string.
pub fn ascii_byte_at(&self, position: usize) -> u8
pub fn ascii_byte_at(&self, position: usize) -> u8
Return the code point at position if it is in the ASCII range,
or `b’\xFF’ otherwise.
§Failure
Fails if position is beyond the end of the string.
pub fn code_points(&self) -> Wtf8CodePoints<'_> ⓘ
pub fn code_points(&self) -> Wtf8CodePoints<'_> ⓘ
Return an iterator for the string’s code points.
pub fn contains_char(&self, ch: char) -> bool
pub fn contains_char(&self, ch: char) -> bool
Returns true if this WTF-8 string contains the given character.
pub fn contains(&self, code_point: CodePoint) -> bool
pub fn contains(&self, code_point: CodePoint) -> bool
Returns true if this WTF-8 string contains the given code point.
pub fn starts_with(&self, pattern: &str) -> bool
pub fn starts_with(&self, pattern: &str) -> bool
Returns true if this WTF-8 string starts with the given UTF-8 string.
pub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Try to convert the string to UTF-8 and return a &str slice.
Return None if the string contains surrogates.
This does not copy the data.
pub fn to_string_lossy(&self) -> Cow<'_, str>
pub fn to_string_lossy(&self) -> Cow<'_, str>
Lossily convert the string to UTF-8.
Return an UTF-8 &str slice if the contents are well-formed in UTF-8.
Surrogates are replaced with "\u{FFFD}" (the replacement character
“�”).
This only copies the data if necessary (if it contains any surrogate).
pub fn to_ill_formed_utf16(&self) -> IllFormedUtf16CodeUnits<'_> ⓘ
pub fn to_ill_formed_utf16(&self) -> IllFormedUtf16CodeUnits<'_> ⓘ
Convert the WTF-8 string to potentially ill-formed UTF-16 and return an iterator of 16-bit code units.
This is lossless:
calling Wtf8Buf::from_ill_formed_utf16 on the resulting code units
would always return the original WTF-8 string.
pub fn to_uppercase(&self) -> Wtf8Buf
pub fn to_uppercase(&self) -> Wtf8Buf
Returns the uppercase equivalent of this wtf8 slice, as a new Wtf8Buf.
pub fn to_lowercase(&self) -> Wtf8Buf
pub fn to_lowercase(&self) -> Wtf8Buf
Returns the lowercase equivalent of this wtf8 slice, as a new Wtf8Buf.
Trait Implementations§
Source§impl Archive for Wtf8Atom
NOT A PUBLIC API
impl Archive for Wtf8Atom
NOT A PUBLIC API
Source§type Resolver = VecResolver
type Resolver = VecResolver
Source§fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
fn resolve(&self, resolver: Self::Resolver, out: Place<Self::Archived>)
§const COPY_OPTIMIZATION: CopyOptimization<Self> = _
const COPY_OPTIMIZATION: CopyOptimization<Self> = _
serialize. Read moreSource§impl<__C: Fallible + ?Sized> CheckBytes<__C> for Wtf8Atomwhere
<__C as Fallible>::Error: Trace,
Wtf8Atom: CheckBytes<__C>,
impl<__C: Fallible + ?Sized> CheckBytes<__C> for Wtf8Atomwhere
<__C as Fallible>::Error: Trace,
Wtf8Atom: CheckBytes<__C>,
Source§impl<'de> Deserialize<'de> for Wtf8Atom
impl<'de> Deserialize<'de> for Wtf8Atom
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<D> Deserialize<Wtf8Atom, D> for ArchivedVec<u8>where
D: ?Sized + Fallible,
<D as Fallible>::Error: Source,
NOT A PUBLIC API
impl<D> Deserialize<Wtf8Atom, D> for ArchivedVec<u8>where
D: ?Sized + Fallible,
<D as Fallible>::Error: Source,
NOT A PUBLIC API
Source§impl Ord for Wtf8Atom
impl Ord for Wtf8Atom
Source§impl PartialOrd for Wtf8Atom
impl PartialOrd for Wtf8Atom
Source§impl<S: Fallible + Writer + Allocator + ?Sized> Serialize<S> for Wtf8Atomwhere
<S as Fallible>::Error: Source,
NOT A PUBLIC API
impl<S: Fallible + Writer + Allocator + ?Sized> Serialize<S> for Wtf8Atomwhere
<S as Fallible>::Error: Source,
NOT A PUBLIC API
impl Eq for Wtf8Atom
impl StructuralPartialEq for Wtf8Atom
Auto Trait Implementations§
impl Freeze for Wtf8Atom
impl RefUnwindSafe for Wtf8Atom
impl Send for Wtf8Atom
impl Sync for Wtf8Atom
impl Unpin for Wtf8Atom
impl UnwindSafe for Wtf8Atom
Blanket Implementations§
§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
§impl<T> ArchiveUnsized for Twhere
T: Archive,
impl<T> ArchiveUnsized for Twhere
T: Archive,
§type Archived = <T as Archive>::Archived
type Archived = <T as Archive>::Archived
Archive, it may be
unsized. Read more§fn archived_metadata(
&self,
) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
fn archived_metadata( &self, ) -> <<T as ArchiveUnsized>::Archived as ArchivePointee>::ArchivedMetadata
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more