Struct std::sys_common::wtf8::CodePoint

source ·
pub struct CodePoint {
    value: u32,
}
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).

Fields§

§value: u32

Implementations§

source§

impl CodePoint

source

pub unsafe fn from_u32_unchecked(value: u32) -> CodePoint

Unsafely creates a new CodePoint without checking the value.

Only use when value is known to be less than or equal to 0x10FFFF.

source

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

source

pub fn from_char(value: char) -> CodePoint

Creates a new CodePoint from a char.

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

source

pub fn to_u32(&self) -> u32

Returns the numeric value of the code point.

source

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

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

source

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

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

source

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

source

pub 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§

source§

impl Clone for CodePoint

source§

fn clone(&self) -> CodePoint

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for CodePoint

Format the code point as U+ followed by four to six hexadecimal digits. Example: U+1F4A9

source§

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

Formats the value using the given formatter. Read more
source§

impl Eq for CodePoint

source§

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.

source§

fn extend<T: IntoIterator<Item = CodePoint>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, code_point: CodePoint)

🔬This is a nightly-only experimental API. (extend_one #72631)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one #72631)
Reserves capacity in a collection for the given number of additional elements. Read more
source§

impl FromIterator<CodePoint> for Wtf8Buf

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

source§

fn from_iter<T: IntoIterator<Item = CodePoint>>(iter: T) -> Wtf8Buf

Creates a value from an iterator. Read more
source§

impl Hash for CodePoint

source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for CodePoint

source§

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

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<CodePoint> for CodePoint

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<CodePoint> for CodePoint

source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Copy for CodePoint

source§

impl StructuralEq for CodePoint

source§

impl StructuralPartialEq for CodePoint

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.