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 leastlen
times len <= capacity
- if
next_unchecked
defers to anotherT: TupleElem
, then you should not callT::next_unchecked
more than once in your ownnext_unchecked
Required Associated Types§
Required Methods§
Sourcefn len(&self) -> usize
fn len(&self) -> usize
The currently initialized length of the data-segment
must be less than or equal to the capacity
Sourcefn into_iterator(self) -> Self::Iter
fn into_iterator(self) -> Self::Iter
Convert to an iterator if we cannot reuse the data-segment
Sourcefn check_layout<V>() -> bool
fn check_layout<V>() -> bool
If this returns true
if it is safe to call
take_output
Sourceunsafe fn take_output<V>(data: &mut Self::Data) -> Output<V>
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.
Sourceunsafe fn next_unchecked(data: &mut Self::Data) -> Self::Item
unsafe fn next_unchecked(data: &mut Self::Data) -> Self::Item
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.