Trait TupleElem

Source
pub unsafe trait TupleElem {
    type Item;
    type Data;
    type Iter: Iterator<Item = Self::Item>;

    // Required methods
    fn capacity(data: &Self::Data) -> usize;
    fn len(&self) -> usize;
    fn into_data(self) -> Self::Data;
    fn into_iterator(self) -> Self::Iter;
    fn check_layout<V>() -> bool;
    unsafe fn take_output<V>(data: &mut Self::Data) -> Output<V>;
    unsafe fn next_unchecked(data: &mut Self::Data) -> Self::Item;
    unsafe fn drop_rest(data: &mut Self::Data, len: usize);
}
Expand description

This trait abstracts away elements of the input stream

§Safety

  • It must be valid to call next_unchecked at least len times
  • len <= capacity
  • if next_unchecked defers to another T: TupleElem, then you should not call T::next_unchecked more than once in your own next_unchecked

Required Associated Types§

Source

type Item

The items yielded from this element

Source

type Data

The data-segment that Output<V> is derived from and yields Items

Source

type Iter: Iterator<Item = Self::Item>

An iterator over the items in the collection

Required Methods§

Source

fn capacity(data: &Self::Data) -> usize

The capacity of the data-segment

Source

fn len(&self) -> usize

The currently initialized length of the data-segment

must be less than or equal to the capacity

Source

fn into_data(self) -> Self::Data

Convert into a raw data-segment

Source

fn into_iterator(self) -> Self::Iter

Convert to an iterator if we cannot reuse the data-segment

Source

fn check_layout<V>() -> bool

If this returns true if it is safe to call take_output

Source

unsafe fn take_output<V>(data: &mut Self::Data) -> Output<V>

Try and create a new output data-segment, if the output segment is created, then it owns it’s allocation. So you must not deallocate the allocation backing Output<V>

§Safety

check_layout::<V> must return true.

Source

unsafe fn next_unchecked(data: &mut Self::Data) -> Self::Item

Get the next_unchecked element

§Safety

This must be called at most len times

Source

unsafe fn drop_rest(data: &mut Self::Data, len: usize)

Drop the rest of the buffer and deallocate if do_pick was never called

§Safety

This function should only be called once, and data should not be used again

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<A> TupleElem for Vec<A>

Source§

type Item = A

Source§

type Data = Input<A>

Source§

type Iter = IntoIter<A>

Source§

fn capacity(data: &Self::Data) -> usize

Source§

fn len(&self) -> usize

Source§

fn into_data(self) -> Self::Data

Source§

fn into_iterator(self) -> Self::Iter

Source§

fn check_layout<V>() -> bool

Source§

unsafe fn take_output<V>(data: &mut Self::Data) -> Output<V>

Source§

unsafe fn next_unchecked(data: &mut Self::Data) -> Self::Item

Source§

unsafe fn drop_rest(data: &mut Self::Data, len: usize)

Source§

impl<A: TupleElem> TupleElem for (A,)

Source§

type Item = <A as TupleElem>::Item

Source§

type Data = <A as TupleElem>::Data

Source§

type Iter = <A as TupleElem>::Iter

Source§

fn capacity(data: &Self::Data) -> usize

Source§

fn len(&self) -> usize

Source§

fn into_data(self) -> Self::Data

Source§

fn into_iterator(self) -> Self::Iter

Source§

fn check_layout<V>() -> bool

Source§

unsafe fn take_output<V>(data: &mut Self::Data) -> Output<V>

Source§

unsafe fn next_unchecked(data: &mut Self::Data) -> Self::Item

Source§

unsafe fn drop_rest(data: &mut Self::Data, len: usize)

Implementors§