[][src]Struct rawslice::SliceIter

pub struct SliceIter<'a, T: 'a> { /* fields omitted */ }

Slice (contiguous data) iterator.

Iterator element type is &T

This iterator exists mainly to have the constructor from a pair of raw pointers available, which the libcore slice iterator does not allow.

The SliceIter's element searching methods all, find, position, rposition are explicitly unrolled so that they often perform better than the libcore slice iterator's variants of those.

Extra Features:

  • unrolled all, find, position, rposition,
  • accessors (incl. mutable) of start, end pointers
  • construct from raw pointers
  • native peek_next
  • native next_unchecked.
  • implement Copy, Index, Default

Notice that we don't have access to or use all the unstable features libcore can use, so some of the perks of the libcore slice iterator are missing.

Missing Features:

  • No TrustedRandomAccess or TrustedLen (unstable features)
  • No std::intrinsics::assume.
  • No support for zero-sized iterator element type

Methods

impl<'a, T> SliceIter<'a, T>[src]

pub unsafe fn new(start: *const T, end: *const T) -> Self[src]

Create a new slice iterator

See also SliceIter::from, SliceIter::default.

Panics if T is a zero-sized type. That case is not supported.

pub fn start(&self) -> *const T[src]

Return the start pointer

pub fn end(&self) -> *const T[src]

Return the end pointer

pub unsafe fn start_mut(&mut self) -> &mut *const T[src]

Return mutable reference to the start pointer

Unsafe because it is easy to violate memory safety by setting the pointer outside the data's valid range.

pub unsafe fn end_mut(&mut self) -> &mut *const T[src]

Return mutable reference to the start pointer

Unsafe because it is easy to violate memory safety by setting the pointer outside the data's valid range.

pub fn peek_next(&self) -> Option<Self::Item>[src]

Return the next iterator element, without stepping the iterator.

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

Return the equivalent slice

pub unsafe fn next_unchecked(&mut self) -> Self::Item[src]

Return the next iterator element, without checking if the end is reached

pub unsafe fn get_unchecked(&self, i: usize) -> &T[src]

Return a reference to the element at i.

Trait Implementations

impl<'a, T> Clone for SliceIter<'a, T>[src]

impl<'a, T> Copy for SliceIter<'a, T>[src]

impl<'a, T: Debug + 'a> Debug for SliceIter<'a, T>[src]

impl<'a, T> Default for SliceIter<'a, T>[src]

fn default() -> Self[src]

Create an empty SliceIter.

impl<'a, T> DoubleEndedIterator for SliceIter<'a, T>[src]

impl<'a, T> ExactSizeIterator for SliceIter<'a, T>[src]

impl<'a, T> From<&'a [T]> for SliceIter<'a, T>[src]

impl<'a, T> From<Iter<'a, T>> for SliceIter<'a, T>[src]

impl<'a, T> Index<usize> for SliceIter<'a, T>[src]

type Output = T

The returned type after indexing.

impl<'a, T> Iterator for SliceIter<'a, T>[src]

type Item = &'a T

The type of the elements being iterated over.

Auto Trait Implementations

impl<'a, T> !Send for SliceIter<'a, T>

impl<'a, T> !Sync for SliceIter<'a, T>

impl<'a, T> Unpin for SliceIter<'a, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.