pub struct Map<'id> { /* private fields */ }Expand description
An Erlang map. Immutable — all mutations return a new map.
Implementations§
Source§impl<'id> Map<'id>
impl<'id> Map<'id>
pub fn from_raw(raw_term: Term) -> Self
Available on crate feature
raw only.Sourcepub fn get(
self,
env: impl Env<'id>,
key: impl Term<'id>,
) -> Option<AnyTerm<'id>>
pub fn get( self, env: impl Env<'id>, key: impl Term<'id>, ) -> Option<AnyTerm<'id>>
Look up key (enif_get_map_value). None if absent.
Sourcepub fn put(
self,
env: impl Env<'id>,
key: impl Term<'id>,
value: impl Term<'id>,
) -> Map<'id>
pub fn put( self, env: impl Env<'id>, key: impl Term<'id>, value: impl Term<'id>, ) -> Map<'id>
Return a new map with key set to value (enif_make_map_put, insert
or replace).
Sourcepub fn update(
self,
env: impl Env<'id>,
key: impl Term<'id>,
value: impl Term<'id>,
) -> Option<Map<'id>>
pub fn update( self, env: impl Env<'id>, key: impl Term<'id>, value: impl Term<'id>, ) -> Option<Map<'id>>
Return a new map with key updated to value (enif_make_map_update).
None if the key is absent.
Sourcepub fn remove(self, env: impl Env<'id>, key: impl Term<'id>) -> Map<'id>
pub fn remove(self, env: impl Env<'id>, key: impl Term<'id>) -> Map<'id>
Return a new map with key removed (enif_make_map_remove). Removing a
key the map does not contain returns it unchanged.
Sourcepub fn is_map(env: impl Env<'id>, term: impl Term<'id>) -> bool
pub fn is_map(env: impl Env<'id>, term: impl Term<'id>) -> bool
Returns true if term is a map (enif_is_map).
Sourcepub fn iter(self, env: impl Env<'id>) -> MapIterator<'id> ⓘ
pub fn iter(self, env: impl Env<'id>) -> MapIterator<'id> ⓘ
Iterate (key, value) pairs in unspecified order.
Trait Implementations§
impl<'id> Copy for Map<'id>
Source§impl<'id> Encoder<'id> for Map<'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 Map<'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 Map<'_>
Source§impl Ord for Map<'_>
impl Ord for Map<'_>
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Map<'_>
impl PartialOrd for Map<'_>
Source§impl<'id> Term<'id> for Map<'id>
impl<'id> Term<'id> for Map<'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,
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 Map<'id>
impl<'id> !Sync for Map<'id>
impl<'id> Freeze for Map<'id>
impl<'id> RefUnwindSafe for Map<'id>
impl<'id> Unpin for Map<'id>
impl<'id> UnsafeUnpin for Map<'id>
impl<'id> UnwindSafe for Map<'id>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more