Enum Utf8Sequence
pub enum Utf8Sequence
Utf8Sequence represents a sequence of byte ranges.
To match a Utf8Sequence, a candidate byte sequence must match each successive range.
For example, if there are two ranges, [C2-DF][80-BF], then the byte
sequence \xDD\x61 would not match because 0x61 < 0x80.
Variants
-
One(Utf8Range) One byte range.
-
Two([Utf8Range; 2]) Two successive byte ranges.
-
Three([Utf8Range; 3]) Three successive byte ranges.
-
Four([Utf8Range; 4]) Four successive byte ranges.
Implementations
impl Utf8Sequence
fn as_slice(&self) -> &[Utf8Range]Returns the underlying sequence of byte ranges as a slice.
fn len(&self) -> usizeReturns the number of byte ranges in this sequence.
The length is guaranteed to be in the closed interval
[1, 4].fn reverse(&mut self)Reverses the ranges in this sequence.
For example, if this corresponds to the following sequence:
[D0-D3][80-BF]Then after reversal, it will be
[80-BF][D0-D3]This is useful when one is constructing a UTF-8 automaton to match character classes in reverse.
fn matches(&self, bytes: &[u8]) -> boolReturns true if and only if a prefix of
bytesmatches this sequence of byte ranges.
Trait Implementations
impl Clone for Utf8Sequence
fn clone(&self) -> Self
impl Copy for Utf8Sequence
impl Debug for Utf8Sequence
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl Eq for Utf8Sequence
impl Ord for Utf8Sequence
fn cmp(&self, other: &Self) -> Ordering
impl PartialEq for Utf8Sequence
fn eq(&self, other: &Self) -> bool
impl PartialOrd for Utf8Sequence
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
impl StructuralPartialEq for Utf8Sequence
Auto Trait Implementations
impl Freeze for Utf8Sequence
impl RefUnwindSafe for Utf8Sequence
impl Send for Utf8Sequence
impl Sync for Utf8Sequence
impl Unpin for Utf8Sequence
impl UnsafeUnpin for Utf8Sequence
impl UnwindSafe for Utf8Sequence
Blanket Implementations
impl<T> Any for Utf8Sequence
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for Utf8Sequence
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for Utf8Sequence
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> CloneToUninit for Utf8Sequence
where
T: Clone,
unsafe fn clone_to_uninit(&self, dest: *mut u8)
impl<T> From<T> for Utf8Sequence
fn from(t: T) -> TReturns the argument unchanged.
impl<T> ToOwned for Utf8Sequence
where
T: Clone,
type Owned = T;fn to_owned(&self) -> Tfn clone_into(&self, target: &mut T)
impl<T, U> Into<U> for Utf8Sequence
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for Utf8Sequence
where
U: Into<T>,
type Error = never;fn try_from(value: U) -> Result<T, never>
impl<T, U> TryInto<U> for Utf8Sequence
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>