Skip to main content

AppendSlice

Struct AppendSlice 

Source
pub struct AppendSlice<'a, T>(/* private fields */);
Expand description

A slice-like view produced by AppendVec::slice.

Internally the vector is backed by multiple exponentially growing buckets. An AppendSlice therefore stores a small SmallVec of slice references so that the common case of spanning at most four buckets is allocated on the stack.

The structure is copy-free and merely borrows the data. Two different iterator flavours are provided:

Implementations§

Source§

impl<'a, T> AppendSlice<'a, T>

Source

pub fn new(slices: &'a [&'a [T]]) -> Self

A view over slices presented as one contiguous sequence.

Source

pub fn get(&self, index: usize) -> Option<&'a T>

Returns a reference to the element at index, or None if the index is out of bounds for this range.

Equivalent to self.into_iter().nth(index) but constant-time.

Source

pub fn len(&self) -> usize

Returns the total number of elements in the range.

Source

pub fn is_empty(&self) -> bool

Returns true if the range contains no elements.

Source

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over the elements in the range.

This is the same iterator that the &AppendSlice implementation of IntoIterator returns.

Trait Implementations§

Source§

impl<'a, T: Debug> Debug for AppendSlice<'a, T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for AppendSlice<'_, T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'a, T> FromIterator<&'a [T]> for AppendSlice<'a, T>

Source§

fn from_iter<I: IntoIterator<Item = &'a [T]>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<T> Index<usize> for AppendSlice<'_, T>

Source§

type Output = T

The returned type after indexing.
Source§

fn index(&self, index: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, T> IntoIterator for AppendSlice<'a, T>

Source§

type IntoIter = AppendSliceIntoIter<'a, T>

Which kind of iterator are we turning this into?
Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'a, 'b, T> IntoIterator for &'b AppendSlice<'a, T>
where 'b: 'a,

Source§

type IntoIter = impl DoubleEndedIterator + FusedIterator + Clone + 'b

Which kind of iterator are we turning this into?
Source§

type Item = &'a T

The type of the elements being iterated over.
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'a, T> Freeze for AppendSlice<'a, T>

§

impl<'a, T> RefUnwindSafe for AppendSlice<'a, T>
where T: RefUnwindSafe,

§

impl<'a, T> Send for AppendSlice<'a, T>
where T: Sync,

§

impl<'a, T> Sync for AppendSlice<'a, T>
where T: Sync,

§

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

§

impl<'a, T> UnsafeUnpin for AppendSlice<'a, T>

§

impl<'a, T> UnwindSafe for AppendSlice<'a, T>
where T: RefUnwindSafe,

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. 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.