pub struct MaybeMarkerCodepoint(/* private fields */);Expand description
A value which is either char or a special marker.
Implementations§
Source§impl MaybeMarkerCodepoint
impl MaybeMarkerCodepoint
Sourcepub const MAX_LEN_UTF8: usize = 4usize
pub const MAX_LEN_UTF8: usize = 4usize
The maximum length of this value, when encoded as UTF8.
Currently 4 bytes, the same as char::MAX_LEN_UTF8.
Sourcepub fn from_u32(x: u32) -> Option<Self>
pub fn from_u32(x: u32) -> Option<Self>
Create this value from a u32,
returning None if invalid.
Sourcepub unsafe fn from_u32_unchecked(u: u32) -> Self
pub unsafe fn from_u32_unchecked(u: u32) -> Self
Create this value from a raw u32,
without checking for validity.
§Safety
Undefined behavior if neither a valid character nor a marker.
Sourcepub fn to_char(&self) -> Result<char, SpecialMarker>
pub fn to_char(&self) -> Result<char, SpecialMarker>
Convert this value into a char,
returning the corresponding marker value otherwise.
Sourcepub fn to_marker(&self) -> Result<SpecialMarker, char>
pub fn to_marker(&self) -> Result<SpecialMarker, char>
Convert this value into a SpecialMarker value,
returning a char otherwise.
Sourcepub fn encode_utf8(&self, output: &mut [u8]) -> usize
pub fn encode_utf8(&self, output: &mut [u8]) -> usize
UTF8 encode this character into a buffer, returning the number of characters which were written.
Differs from char::encode_utf8,
because marker characters are encoded specially
as the corresponding SpecialMarker::utf8_marker.
§Panics
Panics if there is insufficient space to encode this value.
Using Self::MAX_LEN_UTF8 bytes of space is always sufficient.
Trait Implementations§
Source§impl Clone for MaybeMarkerCodepoint
impl Clone for MaybeMarkerCodepoint
Source§fn clone(&self) -> MaybeMarkerCodepoint
fn clone(&self) -> MaybeMarkerCodepoint
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more