#[doc(hidden)] pub struct CodePoint(CodePointInner);
wtf8_internals
)Expand description
A Unicode code point: from U+0000 to U+10FFFF.
Compares with the char
type,
which represents a Unicode scalar value:
a code point that is not a surrogate (U+D800 to U+DFFF).
Tuple Fields§
§0: CodePointInner
wtf8_internals
)Implementations§
Source§impl CodePoint
impl CodePoint
Sourcepub unsafe fn from_u32_unchecked(value: u32) -> CodePoint
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub unsafe fn from_u32_unchecked(value: u32) -> CodePoint
wtf8_internals
)Unsafely creates a new CodePoint
without checking the value.
Only use when value
is known to be less than or equal to 0x10FFFF.
Sourcepub fn from_u32(value: u32) -> Option<CodePoint>
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn from_u32(value: u32) -> Option<CodePoint>
wtf8_internals
)Creates a new CodePoint
if the value is a valid code point.
Returns None
if value
is above 0x10FFFF.
Sourcepub fn from_char(value: char) -> CodePoint
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn from_char(value: char) -> CodePoint
wtf8_internals
)Creates a new CodePoint
from a char
.
Since all Unicode scalar values are code points, this always succeeds.
Sourcepub fn to_u32(&self) -> u32
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn to_u32(&self) -> u32
wtf8_internals
)Returns the numeric value of the code point.
Sourcepub fn to_lead_surrogate(&self) -> Option<u16>
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn to_lead_surrogate(&self) -> Option<u16>
wtf8_internals
)Returns the numeric value of the code point if it is a leading surrogate.
Sourcepub fn to_trail_surrogate(&self) -> Option<u16>
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn to_trail_surrogate(&self) -> Option<u16>
wtf8_internals
)Returns the numeric value of the code point if it is a trailing surrogate.
Sourcepub fn to_char(&self) -> Option<char>
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn to_char(&self) -> Option<char>
wtf8_internals
)Optionally returns a Unicode scalar value for the code point.
Returns None
if the code point is a surrogate (from U+D800 to U+DFFF).
Sourcepub fn to_char_lossy(&self) -> char
🔬This is a nightly-only experimental API. (wtf8_internals
)
pub fn to_char_lossy(&self) -> char
wtf8_internals
)Returns a Unicode scalar value for the code point.
Returns '\u{FFFD}'
(the replacement character “�”)
if the code point is a surrogate (from U+D800 to U+DFFF).
Trait Implementations§
Source§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
Source§impl Ord for CodePoint
impl Ord for CodePoint
Source§impl PartialOrd for CodePoint
impl PartialOrd for CodePoint
Source§#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_lt(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)self == other
, returns ControlFlow::Continue(())
.
Otherwise, returns ControlFlow::Break(self < other)
. Read moreSource§#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_le(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for <=
instead of <
.Source§#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_gt(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for >
instead of <
.Source§#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
#[doc(hidden)] fn __chaining_ge(&self, other: &Rhs) -> ControlFlow<bool>
partial_ord_chaining_methods
)__chaining_lt
, but for >=
instead of <
.