Struct CodePoint
pub struct CodePoint { /* private fields */ }Expand description
A Unicode code point: from U+0000 to U+10FFFF.
Compare with the char type,
which represents a Unicode scalar value:
a code point that is not a surrogate (U+D800 to U+DFFF).
Implementations§
§impl CodePoint
impl CodePoint
pub const unsafe fn from_u32_unchecked(value: u32) -> CodePoint
pub const unsafe fn from_u32_unchecked(value: u32) -> CodePoint
Unsafely create a new CodePoint without checking the value.
§Safety
Only use when value is known to be less than or equal to 0x10FFFF.
pub const fn from_u32(value: u32) -> Option<CodePoint>
pub const fn from_u32(value: u32) -> Option<CodePoint>
Create a new CodePoint if the value is a valid code point.
Return None if value is above 0x10FFFF.
pub const fn from_char(value: char) -> CodePoint
pub const fn from_char(value: char) -> CodePoint
Create a new CodePoint from a char.
Since all Unicode scalar values are code points, this always succeds.
pub fn to_char(&self) -> Option<char>
pub fn to_char(&self) -> Option<char>
Optionally return a Unicode scalar value for the code point.
Return None if the code point is a surrogate (from U+D800 to U+DFFF).
pub fn to_char_lossy(&self) -> char
pub fn to_char_lossy(&self) -> char
Return a Unicode scalar value for the code point.
Return '\u{FFFD}' (the replacement character “�”)
if the code point is a surrogate (from U+D800 to U+DFFF).
Trait Implementations§
§impl Debug for CodePoint
Format the code point as U+ followed by four to six hexadecimal digits.
Example: U+1F4A9
impl Debug for CodePoint
Format the code point as U+ followed by four to six hexadecimal digits.
Example: U+1F4A9
§impl Extend<CodePoint> for Wtf8Buf
Append code points from an iterator to the string.
impl Extend<CodePoint> for Wtf8Buf
Append code points from an iterator to the string.
This replaces surrogate code point pairs with supplementary code points, like concatenating ill-formed UTF-16 strings effectively would.
§fn extend<T>(&mut self, iterable: T)where
T: IntoIterator<Item = CodePoint>,
fn extend<T>(&mut self, iterable: T)where
T: IntoIterator<Item = CodePoint>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)§impl FromIterator<CodePoint> for Wtf8Buf
Create a new WTF-8 string from an iterator of code points.
impl FromIterator<CodePoint> for Wtf8Buf
Create a new WTF-8 string from an iterator of code points.
This replaces surrogate code point pairs with supplementary code points, like concatenating ill-formed UTF-16 strings effectively would.
§impl Ord for CodePoint
impl Ord for CodePoint
§impl PartialOrd for CodePoint
impl PartialOrd for CodePoint
impl Copy for CodePoint
impl Eq for CodePoint
impl StructuralPartialEq for CodePoint
Auto Trait Implementations§
impl Freeze for CodePoint
impl RefUnwindSafe for CodePoint
impl Send for CodePoint
impl Sync for CodePoint
impl Unpin for CodePoint
impl UnwindSafe for CodePoint
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
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