Skip to main content

Char16

Struct Char16 

Source
pub struct Char16(/* private fields */);
Expand description

A 16-bit unicode scalar value, limited to the Basic Multilingual Plane subset.

It can represent every scalar from the Basic Multilingual Plane (BMP), the first and most important plane in the Unicode standard (also known as plane 0), containing nearly all commonly used writing systems and symbols.

Option<Char16> is the same size as Char16 (2 bytes).

See also: Char7, Char8, Char24, Char32, char.

Implementations§

Source§

impl Char16

Source

pub const fn byte_len(self) -> usize

Returns the number of bytes needed to represent the scalar value.

Source

pub const fn len_utf8(self) -> usize

Returns the number of bytes needed to encode in UTF-8.

Source

pub const fn len_utf16(self) -> usize

Returns the number of bytes needed to encode in UTF-16.

Source

pub const fn to_digit(self, radix: u32) -> Option<u32>

Converts the scalar to a digit in the given radix.

‘Digit’ is defined to be only the following characters: 0-9, a-z, A-Z.

§Errors

Returns None if the char does not refer to a digit in the given radix.

§Panics

Panics if given a radix larger than 36.

Source

pub const fn is_nul(self) -> bool

Returns true if this is the nul character (0x00).

Source

pub const fn is_digit(self, radix: u32) -> bool

Checks if the unicode scalar is a digit in the given radix.

See also to_digit.

Source§

impl Char16

Source

pub const MAX: Char16

The highest unicode scalar a Char16 can represent, '\u{FFFF}'.

Note that '\u{FFFF}' is a noncharacter.

Source

pub const REPLACEMENT_CHARACTER: Char16

U+FFFD REPLACEMENT CHARACTER (�) is used in Unicode to represent a decoding error.

Source

pub const fn from_char7(c: Char7) -> Char16

Converts a Char7 to Char16.

Source

pub const fn from_char8(c: Char8) -> Char16

Converts a Char8 to Char16.

Source

pub const fn try_from_char24(c: Char24) -> Result<Char16>

Tries to convert a Char24 to Char16.

Source

pub const fn try_from_char32(c: Char32) -> Result<Char16>

Tries to convert a Char32 to Char16.

Source

pub const fn try_from_char(c: char) -> Result<Char16>

Tries to convert a char to Char16.

Source

pub const fn try_to_char7(self) -> Result<Char7>

Tries to convert this Char16 to Char7.

Source

pub const fn try_to_char8(self) -> Result<Char8>

Tries to convert this Char16 to Char8.

Source

pub const fn to_char24(self) -> Char24

Converts this Char16 to Char24.

Source

pub const fn to_char32(self) -> Char32

Converts this Char16 to Char32.

Source

pub const fn to_char(self) -> char

Converts this Char16 to char.

Source

pub const fn to_u32(self) -> u32

Converts this Char16 to u32.

Source

pub const fn to_utf8_bytes(self) -> [u8; 3]

Converts this Char16 to an UTF-8 encoded sequence of bytes.

Note that this function always returns a 3-byte array, but the actual UTF-8 sequence may be shorter. The unused bytes are set to 0.

Source

pub const fn to_ascii_uppercase(self) -> Char16

Makes a copy of the value in its ASCII upper case equivalent.

ASCII letters ‘a’ to ‘z’ are mapped to ‘A’ to ‘Z’, but non-ASCII letters are unchanged.

Source

pub const fn to_ascii_lowercase(self) -> Char16

Makes a copy of the value in its ASCII lower case equivalent.

ASCII letters ‘A’ to ‘Z’ are mapped to ‘a’ to ‘z’, but non-ASCII letters are unchanged.

Source

pub const fn is_noncharacter(self) -> bool

Returns true if this unicode scalar is a noncharacter.

Source

pub const fn is_character(self) -> bool

Returns true if this unicode scalar is an abstract character.

Source

pub const fn is_ascii(self) -> bool

Checks if the value is within the ASCII range.

Trait Implementations§

Source§

impl Binary for Char16

Source§

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

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

impl Chars for Char16

Source§

const MAX: Self = Self::MAX

The highest unicode scalar that can be represented by this type.
Source§

fn byte_len(self) -> usize

Returns the number of bytes needed to represent the scalar value.
Source§

fn len_utf8(self) -> usize

Returns the number of bytes needed to encode in UTF-8.
Source§

fn len_utf16(self) -> usize

Returns the number of bytes needed to encode in UTF-16.
Source§

fn encode_utf8(self, dst: &mut [u8]) -> &mut str

Encodes this scalar as UTF-8 into the provided byte buffer, and then returns the subslice of the buffer that contains the encoded scalar. Read more
Source§

fn to_utf8_bytes(self) -> [u8; 4]

Converts this scalar to an UTF-8 encoded sequence of bytes. Read more
Source§

fn encode_utf16(self, dst: &mut [u16]) -> &mut [u16]

Encodes this scalar as UTF-16 into the provided byte buffer, and then returns the subslice of the buffer that contains the encoded scalar. Read more
Source§

fn to_digit(self, radix: u32) -> Option<u32>

Converts the scalar to a digit in the given radix. Read more
Source§

fn to_ascii_uppercase(self) -> Self

Makes a copy of the value in its ASCII upper case equivalent. Read more
Source§

fn to_ascii_lowercase(self) -> Self

Makes a copy of the value in its ASCII lower case equivalent. Read more
Source§

fn is_noncharacter(self) -> bool

Returns true if this unicode scalar is a noncharacter.
Source§

fn is_digit(self, radix: u32) -> bool

Checks if the unicode scalar is a digit in the given radix. Read more
Source§

fn is_control(self) -> bool

Returns true if this unicode scalar has the general category for control codes.
Source§

fn is_nul(self) -> bool

Returns true if this unicode scalar is the nul character (0x00).
Source§

fn is_alphabetic(self) -> bool

Returns true if this unicode scalar has the Alphabetic property.
Source§

fn is_numeric(self) -> bool

Returns true if this unicode scalar has one of the general categories for numbers. Read more
Source§

fn is_alphanumeric(self) -> bool

Returns true if this unicode scalar satisfies either is_alphabetic() or is_numeric().
Source§

fn is_lowercase(self) -> bool

Returns true if this unicode scalar has the Lowercase property.
Source§

fn is_uppercase(self) -> bool

Returns true if this unicode scalar has the Lowercase property.
Source§

fn is_whitespace(self) -> bool

Returns true if this unicode scalar has the White_Space property.
Source§

fn is_ascii(self) -> bool

Checks if the value is within the ASCII range.
Source§

fn is_character(self) -> bool
where Self: Sized,

Returns true if this unicode scalar is an abstract character.
Source§

impl Clone for Char16

Source§

fn clone(&self) -> Char16

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Char16

Source§

impl Debug for Char16

Source§

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

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

impl Default for Char16

Returns the default value of \x00 (nul character).

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Display for Char16

Source§

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

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

impl Eq for Char16

Source§

impl From<Char7> for Char16

Source§

fn from(c: Char7) -> Char16

Converts to this type from the input type.
Source§

impl From<Char8> for Char16

Source§

fn from(c: Char8) -> Char16

Converts to this type from the input type.
Source§

impl From<Char16> for Char24

Source§

fn from(c: Char16) -> Char24

Converts to this type from the input type.
Source§

impl From<Char16> for Char32

Source§

fn from(c: Char16) -> Char32

Converts to this type from the input type.
Source§

impl From<Char16> for char

Source§

fn from(c: Char16) -> char

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc24

Source§

fn from(c: Char16) -> NonNulEgc24

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc32

Source§

fn from(c: Char16) -> NonNulEgc32

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc40

Source§

fn from(c: Char16) -> NonNulEgc40

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc48

Source§

fn from(c: Char16) -> NonNulEgc48

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc56

Source§

fn from(c: Char16) -> NonNulEgc56

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc64

Source§

fn from(c: Char16) -> NonNulEgc64

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulEgc128

Source§

fn from(c: Char16) -> NonNulEgc128

Converts to this type from the input type.
Source§

impl From<Char16> for Egc32

Source§

fn from(c: Char16) -> Egc32

Converts to this type from the input type.
Source§

impl From<Char16> for Egc40

Source§

fn from(c: Char16) -> Egc40

Converts to this type from the input type.
Source§

impl From<Char16> for Egc48

Source§

fn from(c: Char16) -> Egc48

Converts to this type from the input type.
Source§

impl From<Char16> for Egc56

Source§

fn from(c: Char16) -> Egc56

Converts to this type from the input type.
Source§

impl From<Char16> for Egc64

Source§

fn from(c: Char16) -> Egc64

Converts to this type from the input type.
Source§

impl From<Char16> for Egc128

Source§

fn from(c: Char16) -> Egc128

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString24

Source§

fn from(c: Char16) -> NonNulString24

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString32

Source§

fn from(c: Char16) -> NonNulString32

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString40

Source§

fn from(c: Char16) -> NonNulString40

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString48

Source§

fn from(c: Char16) -> NonNulString48

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString56

Source§

fn from(c: Char16) -> NonNulString56

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString64

Source§

fn from(c: Char16) -> NonNulString64

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString128

Source§

fn from(c: Char16) -> NonNulString128

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString256

Source§

fn from(c: Char16) -> NonNulString256

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString512

Source§

fn from(c: Char16) -> NonNulString512

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString1024

Source§

fn from(c: Char16) -> NonNulString1024

Converts to this type from the input type.
Source§

impl From<Char16> for NonNulString2048

Source§

fn from(c: Char16) -> NonNulString2048

Converts to this type from the input type.
Source§

impl From<Char16> for String32

Source§

fn from(c: Char16) -> String32

Converts to this type from the input type.
Source§

impl From<Char16> for String40

Source§

fn from(c: Char16) -> String40

Converts to this type from the input type.
Source§

impl From<Char16> for String48

Source§

fn from(c: Char16) -> String48

Converts to this type from the input type.
Source§

impl From<Char16> for String56

Source§

fn from(c: Char16) -> String56

Converts to this type from the input type.
Source§

impl From<Char16> for String64

Source§

fn from(c: Char16) -> String64

Converts to this type from the input type.
Source§

impl From<Char16> for String128

Source§

fn from(c: Char16) -> String128

Converts to this type from the input type.
Source§

impl From<Char16> for String256

Source§

fn from(c: Char16) -> String256

Converts to this type from the input type.
Source§

impl From<Char16> for String512

Source§

fn from(c: Char16) -> String512

Converts to this type from the input type.
Source§

impl From<Char16> for String1024

Source§

fn from(c: Char16) -> String1024

Converts to this type from the input type.
Source§

impl From<Char16> for String2048

Source§

fn from(c: Char16) -> String2048

Converts to this type from the input type.
Source§

impl Hash for Char16

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 LowerHex for Char16

Source§

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

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

impl Octal for Char16

Source§

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

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

impl Ord for Char16

Source§

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

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

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

impl PartialEq for Char16

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Char16

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Strings for Char16

Source§

impl StructuralPartialEq for Char16

Source§

impl TryFrom<Char16> for Char7

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<Char7>

Performs the conversion.
Source§

impl TryFrom<Char16> for Char8

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<Char8>

Performs the conversion.
Source§

impl TryFrom<Char16> for NonNulEgc8

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<NonNulEgc8>

Performs the conversion.
Source§

impl TryFrom<Char16> for NonNulEgc16

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<NonNulEgc16>

Performs the conversion.
Source§

impl TryFrom<Char16> for Egc16

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<Egc16>

Performs the conversion.
Source§

impl TryFrom<Char16> for Egc24

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<Egc24>

Performs the conversion.
Source§

impl TryFrom<Char16> for NonNulString8

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<NonNulString8>

Performs the conversion.
Source§

impl TryFrom<Char16> for NonNulString16

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<NonNulString16>

Performs the conversion.
Source§

impl TryFrom<Char16> for String16

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<String16>

Performs the conversion.
Source§

impl TryFrom<Char16> for String24

Source§

type Error = TextosError

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

fn try_from(c: Char16) -> Result<String24>

Performs the conversion.
Source§

impl TryFrom<Char24> for Char16

Source§

type Error = TextosError

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

fn try_from(c: Char24) -> Result<Char16>

Performs the conversion.
Source§

impl TryFrom<Char32> for Char16

Source§

type Error = TextosError

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

fn try_from(c: Char32) -> Result<Char16>

Performs the conversion.
Source§

impl TryFrom<char> for Char16

Source§

type Error = TextosError

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

fn try_from(c: char) -> Result<Char16>

Performs the conversion.
Source§

impl UpperHex for Char16

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Also for T

Source§

fn also_mut<F>(self, f: F) -> Self
where F: FnOnce(&mut Self),

Applies a function which takes the parameter by exclusive reference, and then returns the (possibly) modified owned value. Read more
Source§

fn also_ref<F>(self, f: F) -> Self
where F: FnOnce(&Self),

Applies a function which takes the parameter by shared reference, and then returns the (possibly) modified owned value. Read more
Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T, Res> Apply<Res> for T
where T: ?Sized,

Source§

fn apply<F>(self, f: F) -> Res
where F: FnOnce(Self) -> Res, Self: Sized,

Apply a function which takes the parameter by value.
Source§

fn apply_ref<F>(&self, f: F) -> Res
where F: FnOnce(&Self) -> Res,

Apply a function which takes the parameter by shared reference.
Source§

fn apply_mut<F>(&mut self, f: F) -> Res
where F: FnOnce(&mut Self) -> Res,

Apply a function which takes the parameter by exclusive reference.
Source§

impl<T> Az for T

Source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

Source§

fn cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> CheckedAs for T

Source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

Source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> OverflowingAs for T

Source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

Source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
Source§

impl<T> SaturatingAs for T

Source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

Source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> UnwrappedAs for T

Source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

Source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
Source§

impl<T> WrappingAs for T

Source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
Source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

Source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.