Struct CodePoint

pub struct CodePoint(pub(in ::wtf8) CodePointInner);

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).

Fields

0: CodePointInner

Implementations

impl CodePoint

unsafe fn from_u32_unchecked(value: u32) -> CodePoint

Unsafely creates a new CodePoint without checking the value.

Safety

value must be less than or equal to 0x10FFFF.

fn from_u32(value: u32) -> Option<CodePoint>

Creates a new CodePoint if the value is a valid code point.

Returns None if value is above 0x10FFFF.

fn from_char(value: char) -> CodePoint

Creates a new CodePoint from a char.

Since all Unicode scalar values are code points, this always succeeds.

fn to_u32(&self) -> u32

Returns the numeric value of the code point.

fn to_lead_surrogate(&self) -> Option<u16>

Returns the numeric value of the code point if it is a leading surrogate.

fn to_trail_surrogate(&self) -> Option<u16>

Returns the numeric value of the code point if it is a trailing surrogate.

fn to_char(&self) -> Option<char>

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).

fn to_char_lossy(&self) -> char

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

impl Clone for CodePoint

fn clone(&self) -> CodePoint

impl Copy for CodePoint

impl Debug for CodePoint

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

impl Eq for CodePoint

fn assert_fields_are_eq(&self)

impl Hash for CodePoint

fn hash<H: Hasher>(&self, state: &mut H)

impl Ord for CodePoint

fn cmp(&self, other: &CodePoint) -> Ordering

impl PartialEq for CodePoint

fn eq(&self, other: &CodePoint) -> bool

impl PartialOrd for CodePoint

fn partial_cmp(&self, other: &CodePoint) -> Option<Ordering>

impl StructuralPartialEq for CodePoint

impl TrivialClone for CodePoint