Skip to main content

Char32

Struct Char32 

Source
#[repr(transparent)]
pub struct Char32(pub char);
Expand description

A 32-bit unicode scalar value.

This is the default unicode scalar type in Rust. It can represent the same range of unicode scalars as Char24.

Option<Char32> is the same size as Char32 or char (4 bytes).

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

Tuple Fields§

§0: char

Implementations§

Source§

impl Char32

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 Char32

Source

pub const MAX: Char32

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

Source

pub const REPLACEMENT_CHARACTER: Char32

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

Source

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

Converts a Char7 to Char32.

Source

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

Converts a Char8 to Char32.

Source

pub const fn from_char16(c: Char16) -> Char32

Converts a Char16 to Char32.

Source

pub const fn from_char24(c: Char24) -> Char32

Converts a Char24 to Char32.

Source

pub const fn from_char(c: char) -> Char32

Converts a char to Char32.

Source

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

Tries to convert this Char32 to Char7.

Source

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

Tries to convert this Char32 to Char8.

Source

pub const fn try_to_char16(self) -> Result<Char16>

Tries to convert this Char32 to Char16.

Source

pub const fn to_char24(self) -> Char24

Converts this Char32 to Char24.

Source

pub const fn to_char(self) -> char

Converts this Char32 to char.

Source

pub const fn to_u32(self) -> u32

Converts this Char32 to u32.

Source

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

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

Note that this function always returns a 4-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) -> Char32

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

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 Char32

Source§

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

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

impl Chars for Char32

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 Char32

Source§

fn clone(&self) -> Char32

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 Char32

Source§

impl Debug for Char32

Source§

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

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

impl Default for Char32

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 Char32

Source§

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

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

impl Eq for Char32

Source§

impl From<Char7> for Char32

Source§

fn from(c: Char7) -> Char32

Converts to this type from the input type.
Source§

impl From<Char8> for Char32

Source§

fn from(c: Char8) -> Char32

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<Char24> for Char32

Source§

fn from(c: Char24) -> Char32

Converts to this type from the input type.
Source§

impl From<Char32> for Char24

Source§

fn from(c: Char32) -> Char24

Converts to this type from the input type.
Source§

impl From<Char32> for char

Source§

fn from(c: Char32) -> char

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulEgc32

Source§

fn from(c: Char32) -> NonNulEgc32

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulEgc40

Source§

fn from(c: Char32) -> NonNulEgc40

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulEgc48

Source§

fn from(c: Char32) -> NonNulEgc48

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulEgc56

Source§

fn from(c: Char32) -> NonNulEgc56

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulEgc64

Source§

fn from(c: Char32) -> NonNulEgc64

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulEgc128

Source§

fn from(c: Char32) -> NonNulEgc128

Converts to this type from the input type.
Source§

impl From<Char32> for Egc40

Source§

fn from(c: Char32) -> Egc40

Converts to this type from the input type.
Source§

impl From<Char32> for Egc48

Source§

fn from(c: Char32) -> Egc48

Converts to this type from the input type.
Source§

impl From<Char32> for Egc56

Source§

fn from(c: Char32) -> Egc56

Converts to this type from the input type.
Source§

impl From<Char32> for Egc64

Source§

fn from(c: Char32) -> Egc64

Converts to this type from the input type.
Source§

impl From<Char32> for Egc128

Source§

fn from(c: Char32) -> Egc128

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString32

Source§

fn from(c: Char32) -> NonNulString32

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString40

Source§

fn from(c: Char32) -> NonNulString40

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString48

Source§

fn from(c: Char32) -> NonNulString48

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString56

Source§

fn from(c: Char32) -> NonNulString56

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString64

Source§

fn from(c: Char32) -> NonNulString64

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString128

Source§

fn from(c: Char32) -> NonNulString128

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString256

Source§

fn from(c: Char32) -> NonNulString256

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString512

Source§

fn from(c: Char32) -> NonNulString512

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString1024

Source§

fn from(c: Char32) -> NonNulString1024

Converts to this type from the input type.
Source§

impl From<Char32> for NonNulString2048

Source§

fn from(c: Char32) -> NonNulString2048

Converts to this type from the input type.
Source§

impl From<Char32> for String40

Source§

fn from(c: Char32) -> String40

Converts to this type from the input type.
Source§

impl From<Char32> for String48

Source§

fn from(c: Char32) -> String48

Converts to this type from the input type.
Source§

impl From<Char32> for String56

Source§

fn from(c: Char32) -> String56

Converts to this type from the input type.
Source§

impl From<Char32> for String64

Source§

fn from(c: Char32) -> String64

Converts to this type from the input type.
Source§

impl From<Char32> for String128

Source§

fn from(c: Char32) -> String128

Converts to this type from the input type.
Source§

impl From<Char32> for String256

Source§

fn from(c: Char32) -> String256

Converts to this type from the input type.
Source§

impl From<Char32> for String512

Source§

fn from(c: Char32) -> String512

Converts to this type from the input type.
Source§

impl From<Char32> for String1024

Source§

fn from(c: Char32) -> String1024

Converts to this type from the input type.
Source§

impl From<Char32> for String2048

Source§

fn from(c: Char32) -> String2048

Converts to this type from the input type.
Source§

impl From<char> for Char32

Source§

fn from(c: char) -> Char32

Converts to this type from the input type.
Source§

impl Hash for Char32

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 Char32

Source§

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

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

impl Octal for Char32

Source§

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

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

impl Ord for Char32

Source§

fn cmp(&self, other: &Char32) -> 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 Char32

Source§

fn eq(&self, other: &Char32) -> 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 Char32

Source§

fn partial_cmp(&self, other: &Char32) -> 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 Char32

Source§

impl StructuralPartialEq for Char32

Source§

impl TryFrom<Char32> for Char7

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for Char8

Source§

type Error = TextosError

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

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

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<Char32> for NonNulEgc8

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for NonNulEgc16

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for NonNulEgc24

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for Egc16

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for Egc24

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for Egc32

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for NonNulString8

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for NonNulString16

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for NonNulString24

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for String16

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for String24

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl TryFrom<Char32> for String32

Source§

type Error = TextosError

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

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

Performs the conversion.
Source§

impl UpperHex for Char32

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.