pub struct PreparedThreeBytes {
first: u8,
second: u8,
third: u8,
check: u8,
}Expand description
Wrapper for the first three bytes and a precomputed value.
Fields§
§first: u8§second: u8§third: u8§check: u8§Safety invariant
If first is not a lead byte for a two-byte sequence,
check is 0b10 iff first, second, and third
form a well-formed three-byte UTF-8 sequence or a
three-byte prefix of a four-byte UTF-8 sequence.
(Establish that first is not a lead byte for a two-byte
sequence when making use of check.)
Implementations§
Source§impl PreparedThreeBytes
impl PreparedThreeBytes
Sourcepub const fn new(first: u8, second: u8, third: u8) -> Self
pub const fn new(first: u8, second: u8, third: u8) -> Self
Constructor
first, second, and third represent the first three bytes of a
potential UTF-8 sequence for efficient checking for whether
they actually form a prefix of a well-formed UTF-8 sequence.
Sourcepub const fn new_with_prepared(prepared: PreparedTwoBytes, third: u8) -> Self
pub const fn new_with_prepared(prepared: PreparedTwoBytes, third: u8) -> Self
Constructor with already-prepared first two bytes
prepared and third represent the first three bytes of a
potential UTF-8 sequence for efficient checking for whether
they actually form a prefix of a well-formed UTF-8 sequence.
Sourcepub const fn prefix_of_four_byte(self) -> bool
pub const fn prefix_of_four_byte(self) -> bool
Return true iff these three bytes represent a three-byte
prefix of a well-formed four-byte UTF-8 sequence.
§Safety-usable invariant
The caller may rely on the result for safety.
Trait Implementations§
Source§impl Clone for PreparedThreeBytes
impl Clone for PreparedThreeBytes
Source§fn clone(&self) -> PreparedThreeBytes
fn clone(&self) -> PreparedThreeBytes
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more