Skip to main content

TupleView

Struct TupleView 

Source
pub struct TupleView<'id> { /* private fields */ }
Expand description

A Tuple whose elements have been resolved, produced by Tuple::with_elements.

It is still a tuple Term (it carries the original term word, so it encodes and compares like one), and additionally behaves as a fixed-size collection of its elements: len/is_empty, tuple[i] indexing, and iteration, all yielding AnyTerm<'id> — the unresolved element terms. enif_get_tuple returns a pointer into the boxed tuple’s own heap storage (it hands back tuple_val(t)+1, confirmed in the ERTS source); the process heap holds that at a fixed address for the duration of a NIF call (no GC mid-NIF), so the cached slice is valid for this view’s brand 'id and the type stays Copy.

Implementations§

Source§

impl<'id> TupleView<'id>

Source

pub fn len(self) -> usize

Number of elements (arity) of the tuple.

Source

pub fn is_empty(self) -> bool

Returns true if the tuple has zero elements.

Trait Implementations§

Source§

impl<'id> Clone for TupleView<'id>

Source§

fn clone(&self) -> TupleView<'id>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'id> Copy for TupleView<'id>

Source§

impl Debug for TupleView<'_>

Source§

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

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

impl<'id> Encoder<'id> for TupleView<'id>

Encodes for free by rewrapping the term’s own machine word — an otter term is already an Erlang term. Never fails.

Source§

fn encode(&self, env: impl Env<'id>) -> Result<AnyTerm<'id>, CodecError>

Source§

impl<'id> Index<usize> for TupleView<'id>

Source§

fn index(&self, i: usize) -> &AnyTerm<'id>

The element at zero-based index i. Panics if i >= self.len().

Source§

type Output = AnyTerm<'id>

The returned type after indexing.
Source§

impl<'id> IntoIterator for TupleView<'id>

Source§

type Item = AnyTerm<'id>

The type of the elements being iterated over.
Source§

type IntoIter = Copied<Iter<'id, AnyTerm<'id>>>

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

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl<'id> Term<'id> for TupleView<'id>

Source§

fn raw_term(self) -> Term

The raw machine word backing this term.
Source§

fn copy_to<'dst>(self, env: impl Env<'dst>) -> AnyTerm<'dst>
where Self: Sized,

Copy this term into another environment (enif_make_copy), producing a term branded to the destination. The general cross-env copy — distinct from same-brand Encoder (which wraps for free) and from OwnedEnvArena copy_out (the arena exit).

Auto Trait Implementations§

§

impl<'id> !Send for TupleView<'id>

§

impl<'id> !Sync for TupleView<'id>

§

impl<'id> Freeze for TupleView<'id>

§

impl<'id> RefUnwindSafe for TupleView<'id>

§

impl<'id> Unpin for TupleView<'id>

§

impl<'id> UnsafeUnpin for TupleView<'id>

§

impl<'id> UnwindSafe for TupleView<'id>

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, dest: *mut u8)

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