pub struct PartialCodePoint(/* private fields */);Expand description
A type which represents part of a utf-8 code point
It does not know which part of a code point it represents (e.g. utf-8 first or later byte of a code point > 0x7f).
When used in a iteration like context it is also not guaranteed to go through all utf-8 bytes, it might, or it might just represent the first byte replacing all bytes > 0x7f with 0xFF.
This allows efficiently abstracting over char sequences and utf-8 byte sequences for tasks which are mainly focused on us-ascii and treat all non ascii utf8 code points the same.
Implementations§
Source§impl PartialCodePoint
impl PartialCodePoint
pub fn as_u8(self) -> u8
Sourcepub fn from_utf8_byte(u8b: u8) -> PartialCodePoint
pub fn from_utf8_byte(u8b: u8) -> PartialCodePoint
creates a partial code point from a utf8 byte
The inner value will be the byte passed in, which should not be 0xff as 0xff doesn’t appear in a utf-8 byte sequence
§Debug Assertions
if debug assertions are enabled and 0xff is passed in this will panic as it wasn’t created from a byte from a utf-8 byte sequence
Sourcepub fn from_code_point(code_point: u32) -> PartialCodePoint
pub fn from_code_point(code_point: u32) -> PartialCodePoint
creates a PartialCodePoint from a utf-8 code point.
The inner value will be:
- the char if the code point is us-ascii
- 0xFF if it is larger then 0x7f i.e. non us-ascii
Trait Implementations§
Source§impl Clone for PartialCodePoint
impl Clone for PartialCodePoint
Source§fn clone(&self) -> PartialCodePoint
fn clone(&self) -> PartialCodePoint
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for PartialCodePoint
Source§impl Debug for PartialCodePoint
impl Debug for PartialCodePoint
impl Eq for PartialCodePoint
Source§impl Hash for PartialCodePoint
impl Hash for PartialCodePoint
Source§impl Ord for PartialCodePoint
impl Ord for PartialCodePoint
Source§fn cmp(&self, other: &PartialCodePoint) -> Ordering
fn cmp(&self, other: &PartialCodePoint) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for PartialCodePoint
impl PartialEq for PartialCodePoint
Source§fn eq(&self, other: &PartialCodePoint) -> bool
fn eq(&self, other: &PartialCodePoint) -> bool
self and other values to be equal, and is used by ==.