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§

source§

impl<'a, const FORMAT: u128> Bytes<'a, FORMAT>

source

pub const IS_CONTIGUOUS: bool = _

If each yielded value is adjacent in memory.

source

pub fn new(slc: &'a [u8]) -> Self

Create new byte object.

source

pub fn as_ptr(&self) -> *const u8

Get a ptr to the current start of the iterator.

source

pub fn as_slice(&self) -> &'a [u8]

Get a slice to the current start of the iterator.

source

pub fn length(&self) -> usize

Get the total number of elements in the underlying slice.

source

pub fn cursor(&self) -> usize

Get the current index of the iterator in the slice.

source

pub unsafe fn set_cursor(&mut self, index: usize)

Set the current index of the iterator in the slice.

§Safety

Safe if index <= self.length().

source

pub fn current_count(&self) -> usize

Get the current number of values returned by the iterator.

source

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().

source

pub fn is_contiguous(&self) -> bool

source

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.

source

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.

source

pub fn first_is(&mut self, value: u8) -> bool

Check if the next element is a given value.

source

pub fn case_insensitive_first_is(&mut self, value: u8) -> bool

Check if the next element is a given value without case sensitivity.

source

pub fn integer_iter<'b>(&'b mut self) -> IntegerBytesIterator<'a, 'b, FORMAT>

Get iterator over integer digits.

source

pub fn fraction_iter<'b>(&'b mut self) -> FractionBytesIterator<'a, 'b, FORMAT>

Get iterator over fraction digits.

source

pub fn exponent_iter<'b>(&'b mut self) -> ExponentBytesIterator<'a, 'b, FORMAT>

Get iterator over exponent digits.

source

pub fn special_iter<'b>(&'b mut self) -> SpecialBytesIterator<'a, 'b, FORMAT>

Get iterator over special floating point values.

source

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.

source

pub unsafe fn step_unchecked(&mut self)

Advance the byte by 1 element.

§Safety

Safe as long as the iterator is not empty.

Trait Implementations§

source§

impl<'a, const FORMAT: u128> Clone for Bytes<'a, FORMAT>

source§

fn clone(&self) -> Bytes<'a, FORMAT>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<'a, const FORMAT: u128> Freeze for Bytes<'a, FORMAT>

§

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.