lexical_util::iterator

Struct 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 fn new(slc: &'a [u8]) -> Self

Create new byte object.

Source

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

Get iterator over integer digits.

Source

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

Get iterator over fraction digits.

Source

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

Get iterator over exponent digits.

Source

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

Get iterator over special floating point values.

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
Source§

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

Source§

const IS_CONTIGUOUS: bool = _

If each yielded value is adjacent in memory.

Source§

fn cursor(&self) -> usize

Get the current index of the iterator in the slice.

Source§

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

Set the current index of the iterator in the slice.

§Safety

Safe if index <= self.buffer_length().

Source§

fn current_count(&self) -> usize

Get the current number of digits returned by the iterator.

For contiguous iterators, this can include the sign character, decimal point, and the exponent sign (that is, it is always the cursor). For non-contiguous iterators, this must always be the only the number of digits returned.

Source§

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

Get a slice to the full underlying contiguous buffer,
Source§

unsafe fn step_by_unchecked(&mut self, count: usize)

Advance the internal slice by N elements. Read more
Source§

unsafe fn peek_many_unchecked<V>(&self) -> V

Read a value of a difference type from the iterator. Read more
Source§

fn as_ptr(&self) -> *const u8

Get a ptr to the current start of the buffer.
Source§

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

Get a slice to the current start of the buffer.
Source§

fn buffer_length(&self) -> usize

Get the total number of elements in the underlying buffer.
Source§

fn is_buffer_empty(&self) -> bool

Get if no bytes are available in the buffer. Read more
Source§

fn is_contiguous(&self) -> bool

Determine if the buffer is contiguous.
Source§

fn first(&self) -> Option<&'a u8>

Get the next value available without consuming it. Read more
Source§

fn first_is_cased(&self, value: u8) -> bool

Check if the next element is a given value.
Source§

fn first_is_uncased(&self, value: u8) -> bool

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

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

Check if the next item in buffer is a given value with optional case sensitivity.
Source§

unsafe fn step_unchecked(&mut self)

Advance the internal slice by 1 element. Read more
Source§

fn peek_u32(&self) -> Option<u32>

Try to read a the next four bytes as a u32. Read more
Source§

fn peek_u64(&self) -> Option<u64>

Try to read the next eight bytes as a u64. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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,

Source§

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>,

Source§

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>,

Source§

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.