pub struct Tuple<'id> { /* private fields */ }Expand description
An Erlang tuple.
The lean form: a one-word term handle, like every other otter term. Reading
its elements is an explicit step — with_elements
performs the single enif_get_tuple and yields a TupleView, the
collection-like form. Keeping the two separate means a tuple that is only
passed through (matched in TypedTerm, re-encoded, compared) never pays for
the element fetch.
Implementations§
Source§impl<'id> Tuple<'id>
impl<'id> Tuple<'id>
pub fn from_raw(raw_term: Term) -> Self
raw only.Sourcepub fn with_elements(self, env: impl Env<'id>) -> TupleView<'id>
pub fn with_elements(self, env: impl Env<'id>) -> TupleView<'id>
Resolve the tuple’s elements (one enif_get_tuple) into a TupleView.
A Tuple is only ever built from a term already confirmed to be a tuple,
so enif_get_tuple cannot fail — a zero return is an internal contract
violation, not a user-input case, hence the assert.
Sourcepub fn from_terms<I, T>(env: impl Env<'id>, terms: I) -> Tuple<'id>where
I: IntoIterator<Item = T>,
T: Term<'id>,
pub fn from_terms<I, T>(env: impl Env<'id>, terms: I) -> Tuple<'id>where
I: IntoIterator<Item = T>,
T: Term<'id>,
Construct a tuple from any iterable of terms of this brand
(enif_make_tuple_from_array).
Trait Implementations§
impl<'id> Copy for Tuple<'id>
Source§impl<'id> Decoder<'id> for Tuple<'id>
Accepts a tuple of any arity (enif_is_tuple);
WrongType otherwise.
impl<'id> Decoder<'id> for Tuple<'id>
Accepts a tuple of any arity (enif_is_tuple);
WrongType otherwise.
Source§impl<'id> Encoder<'id> for Tuple<'id>
Encodes for free by rewrapping the term’s own machine word — an otter
term is already an Erlang term. Never fails.
impl<'id> Encoder<'id> for Tuple<'id>
Encodes for free by rewrapping the term’s own machine word — an otter term is already an Erlang term. Never fails.
impl Eq for Tuple<'_>
Source§impl Ord for Tuple<'_>
impl Ord for Tuple<'_>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialOrd for Tuple<'_>
impl PartialOrd for Tuple<'_>
Source§impl<'id> Term<'id> for Tuple<'id>
impl<'id> Term<'id> for Tuple<'id>
Source§fn copy_to<'dst>(self, env: impl Env<'dst>) -> AnyTerm<'dst>where
Self: Sized,
fn copy_to<'dst>(self, env: impl Env<'dst>) -> AnyTerm<'dst>where
Self: Sized,
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).