Struct Utf8Sequences
struct Utf8Sequences { ... }
An iterator over ranges of matching UTF-8 byte sequences.
The iteration represents an alternation of comprehensive byte sequences that match precisely the set of UTF-8 encoded scalar values.
A byte sequence corresponds to one of the scalar values in the range given if and only if it completely matches exactly one of the sequences of byte ranges produced by this iterator.
Each sequence of byte ranges matches a unique set of bytes. That is, no two sequences will match the same bytes.
Example
This shows how to match an arbitrary byte sequence against a range of scalar values.
use ;
// Test the basic multilingual plane.
let seqs: = new.collect;
// UTF-8 encoding of 'a'.
assert!;
// UTF-8 encoding of '☃' (`\u{2603}`).
assert!;
// UTF-8 encoding of `\u{10348}` (outside the BMP).
assert!;
// Tries to match against a UTF-8 encoding of a surrogate codepoint,
// which is invalid UTF-8, and therefore fails, despite the fact that
// the corresponding codepoint (0xD800) falls in the range given.
assert!;
// And fails against plain old invalid UTF-8.
assert!;
If this example seems circuitous, that's because it is! It's meant to be illustrative. In practice, you could just try to decode your byte sequence and compare it with the scalar value range directly. However, this is not always possible (for example, in a byte based automaton).
Implementations
impl Utf8Sequences
fn new(start: char, end: char) -> SelfCreate a new iterator over UTF-8 byte ranges for the scalar value range given.
impl Debug for Utf8Sequences
fn fmt(self: &Self, f: &mut Formatter<'_>) -> Result
impl Freeze for Utf8Sequences
impl FusedIterator for Utf8Sequences
impl Iterator for Utf8Sequences
fn next(self: &mut Self) -> Option<<Self as >::Item>
impl RefUnwindSafe for Utf8Sequences
impl Send for Utf8Sequences
impl Sync for Utf8Sequences
impl Unpin for Utf8Sequences
impl UnsafeUnpin for Utf8Sequences
impl UnwindSafe for Utf8Sequences
impl<I> IntoIterator for Utf8Sequences
fn into_iter(self: Self) -> I
impl<T> Any for Utf8Sequences
fn type_id(self: &Self) -> TypeId
impl<T> Borrow for Utf8Sequences
fn borrow(self: &Self) -> &T
impl<T> BorrowMut for Utf8Sequences
fn borrow_mut(self: &mut Self) -> &mut T
impl<T> From for Utf8Sequences
fn from(t: T) -> TReturns the argument unchanged.
impl<T, U> Into for Utf8Sequences
fn into(self: Self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom for Utf8Sequences
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto for Utf8Sequences
fn try_into(self: Self) -> Result<U, <U as TryFrom<T>>::Error>