Struct lexical_util::iterator::Bytes
source · [−]pub struct Bytes<'a, const FORMAT: u128> { /* private fields */ }
Expand description
Slice iterator that skips characters matching a given value.
This wraps an iterator over a contiguous block of memory, and only returns values that are not equal to skip.
The format allows us to dictate the actual behavior of the iterator: in what contexts does it skip digit separators.
FORMAT
is required to tell us what the digit separator is, and where
the digit separators are allowed, as well tell us the radix.
The radix is required to allow us to differentiate digit from
non-digit characters (see DigitSeparators
for a detailed explanation on why).
Implementations
sourceimpl<'a, const FORMAT: u128> Bytes<'a, FORMAT>
impl<'a, const FORMAT: u128> Bytes<'a, FORMAT>
sourcepub const IS_CONTIGUOUS: bool = NumberFormat::<{ FORMAT }>::DIGIT_SEPARATOR == 0
pub const IS_CONTIGUOUS: bool = NumberFormat::<{ FORMAT }>::DIGIT_SEPARATOR == 0
If each yielded value is adjacent in memory.
sourcepub fn as_slice(&self) -> &'a [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
pub fn as_slice(&self) -> &'a [u8]ⓘNotable traits for &'_ mut [u8]impl<'_> Write for &'_ mut [u8]impl<'_> Read for &'_ [u8]
Get a slice to the current start of the iterator.
sourcepub unsafe fn set_cursor(&mut self, index: usize)
pub unsafe fn set_cursor(&mut self, index: usize)
sourcepub fn current_count(&self) -> usize
pub fn current_count(&self) -> usize
Get the current number of values returned by the iterator.
sourcepub fn is_done(&self) -> bool
pub fn is_done(&self) -> bool
Get if the buffer underlying the iterator is empty.
This might not be the same thing as is_consumed
: is_consumed
checks if any more elements may be returned, which may require
peeking the next value. Consumed merely checks if the
iterator has an empty slice. It is effectively a cheaper,
but weaker variant of is_consumed()
.
pub fn is_contiguous(&self) -> bool
sourcepub unsafe fn read_unchecked<V>(&self) -> V
pub unsafe fn read_unchecked<V>(&self) -> V
Read a value of a difference type from the iterator. This advances the internal state of the iterator.
Safety
Safe as long as the number of the buffer is contains as least as many bytes as the size of V.
sourcepub fn read<V>(&self) -> Option<V>
pub fn read<V>(&self) -> Option<V>
Try to read a value of a different type from the iterator. This advances the internal state of the iterator.
sourcepub fn case_insensitive_first_is(&mut self, value: u8) -> bool
pub fn case_insensitive_first_is(&mut self, value: u8) -> bool
Check if the next element is a given value without case sensitivity.
sourcepub fn integer_iter<'b>(&'b mut self) -> IntegerBytesIterator<'a, 'b, FORMAT>
pub fn integer_iter<'b>(&'b mut self) -> IntegerBytesIterator<'a, 'b, FORMAT>
Get iterator over integer digits.
sourcepub fn fraction_iter<'b>(&'b mut self) -> FractionBytesIterator<'a, 'b, FORMAT>
pub fn fraction_iter<'b>(&'b mut self) -> FractionBytesIterator<'a, 'b, FORMAT>
Get iterator over fraction digits.
sourcepub fn exponent_iter<'b>(&'b mut self) -> ExponentBytesIterator<'a, 'b, FORMAT>
pub fn exponent_iter<'b>(&'b mut self) -> ExponentBytesIterator<'a, 'b, FORMAT>
Get iterator over exponent digits.
sourcepub fn special_iter<'b>(&'b mut self) -> SpecialBytesIterator<'a, 'b, FORMAT>
pub fn special_iter<'b>(&'b mut self) -> SpecialBytesIterator<'a, 'b, FORMAT>
Get iterator over special floating point values.
sourcepub unsafe fn step_by_unchecked(&mut self, count: usize)
pub unsafe fn step_by_unchecked(&mut self, count: usize)
Advance the byte by N
elements.
Safety
As long as the iterator is at least N
elements, this
is safe.
sourcepub unsafe fn step_unchecked(&mut self)
pub unsafe fn step_unchecked(&mut self)
Trait Implementations
Auto Trait Implementations
impl<'a, const FORMAT: u128> RefUnwindSafe for Bytes<'a, FORMAT>
impl<'a, const FORMAT: u128> Send for Bytes<'a, FORMAT>
impl<'a, const FORMAT: u128> Sync for Bytes<'a, FORMAT>
impl<'a, const FORMAT: u128> Unpin for Bytes<'a, FORMAT>
impl<'a, const FORMAT: u128> UnwindSafe for Bytes<'a, FORMAT>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more