Struct Map
#[repr(transparent)]
pub struct Map<K = JsValue, V = JsValue> { /* private fields */ }
Implementations
impl Map
fn new() -> MapThe Map object holds key-value pairs. Any value (both objects and primitive values) maybe used as either a key or a value.
Note: Consider using
Map::new_typedfor typing support.
impl<K, V> Map<K, V>
fn try_for_each(&self, callback: &mut dyn FnMut(V, K) -> Result<(), JsError>) -> Result<(), JsValue> where dyn FnMut(V, K) -> Result<(), JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> Result<(), JsError>>,The
forEach()method executes a provided function once per each key/value pair in the Map object, in insertion order. (Fallible variation) Note that in Javascript land theKeyandValueare reversed compared to normal expectations:Examples
let js_map = Map::new(); js_map.for_each(&mut |value, key| { // Do something here... })Note: Consider using
Map::try_for_eachif the callback might throw an error.
impl<K, V> Map<K, V>
fn get(&self, key: &K) -> V where K: ErasableGenericBorrow<JsValue>, V: ErasableGenericOwn<JsValue>,The
get()method returns a specified element from a Map object. Returnsundefinedif the key is not found.Note: Consider using
Map::get_checkedto get anOption<V>instead.
impl<K, V> Map<K, V>
fn has(&self, key: &K) -> bool where K: ErasableGenericBorrow<JsValue>,The
has()method returns a boolean indicating whether an element with the specified key exists or not.
impl<K, V> Map<K, V>
fn new_typed() -> Map<K, V> where Map<K, V>: ErasableGenericOwn<Map<JsValue, JsValue>>,The Map object holds key-value pairs. Any value (both objects and primitive values) maybe used as either a key or a value.
impl<K, V> Map<K, V>
fn delete(&self, key: &K) -> bool where K: ErasableGenericBorrow<JsValue>,The
delete()method removes the specified element from a Map object.
impl<K, V> Map<K, V>
fn set(&self, key: &K, value: &V) -> Map<K, V> where K: ErasableGenericBorrow<JsValue>, V: ErasableGenericBorrow<JsValue>, Map<K, V>: ErasableGenericOwn<Map<JsValue, JsValue>>,The
set()method adds or updates an element with a specified key and value to a Map object.
impl<K, V> Map<K, V>
fn new_from_entries<I>(entries: &I) -> Map<K, V> where I: Iterable<Item = ArrayTuple<(K, V)>> + ErasableGenericBorrow<JsValue>, Map<K, V>: ErasableGenericOwn<Map<JsValue, JsValue>>,The Map object holds key-value pairs. Any value (both objects and primitive values) maybe used as either a key or a value.
impl<K, V> Map<K, V>
fn for_each(&self, callback: &mut dyn FnMut(V, K)) where dyn FnMut(V, K): ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue)>,The
forEach()method executes a provided function once per each key/value pair in the Map object, in insertion order. Note that in Javascript land theKeyandValueare reversed compared to normal expectations:Examples
let js_map = Map::new(); js_map.for_each(&mut |value, key| { // Do something here... })
impl<K, V> Map<K, V>
fn get_checked(&self, key: &K) -> Option<V> where K: ErasableGenericBorrow<JsValue>, Option<V>: ErasableGenericOwn<Option<JsValue>>,The
get()method returns a specified element from a Map object. ReturnsNoneif the key is not found.
impl<K, V> Map<K, V>
fn size(&self) -> u32The value of size is an integer representing how many entries the Map object has. A set accessor function for size is undefined; you can not change this property.
impl<K, V> Map<K, V>
fn clear(&self)The
clear()method removes all elements from a Map object.
impl<K, V> Map<K, V>
where
K: FromWasmAbi,
V: FromWasmAbi,
fn keys(&self) -> Iterator<K> where Iterator<K>: ErasableGenericOwn<Iterator<JsValue>>,The
keys()method returns a new Iterator object that contains the keys for each element in the Map object in insertion order.
impl<K, V> Map<K, V>
where
K: JsGeneric,
V: FromWasmAbi + JsGeneric,
fn entries_typed(&self) -> Iterator<ArrayTuple<(K, V)>> where Iterator<ArrayTuple<(K, V)>>: ErasableGenericOwn<Iterator<ArrayTuple<(JsValue, JsValue)>>>,The
entries()method returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
impl<K, V> Map<K, V>
where
V: FromWasmAbi,
fn entries(&self) -> IteratorThe
entries()method returns a new Iterator object that contains the [key, value] pairs for each element in the Map object in insertion order.
impl<K, V> Map<K, V>
where
V: FromWasmAbi,
fn values(&self) -> Iterator<V> where Iterator<V>: ErasableGenericOwn<Iterator<JsValue>>,The
values()method returns a new Iterator object that contains the values for each element in the Map object in insertion order.
Trait Implementations
impl Default for Map<JsValue, JsValue>
fn default() -> Self
impl From<JsValue> for Map
fn from(obj: JsValue) -> Self
impl<K, V> AsRef<JsValue> for Map<K, V>
fn as_ref(&self) -> &JsValue
impl<K, V> AsRef<Map<K, V>> for Map<K, V>
fn as_ref(&self) -> &Map<K, V>
impl<K, V> AsRef<Object> for Map<K, V>
fn as_ref(&self) -> &Object
impl<K, V> Deref for Map<K, V>
type Target = Object;fn deref(&self) -> &Object
impl<K, V> ErasableGeneric for Map<K, V>
type Repr = JsValue;
impl<K, V> FromWasmAbi for Map<K, V>
type Abi = <JsValue as FromWasmAbi>::Abi;unsafe fn from_abi(js: Self::Abi) -> Self
impl<K, V> IntoJsGeneric for Map<K, V>
where
Map<K, V>: JsGeneric,
type JsCanon = Map<K, V>;fn to_js(self) -> Map<K, V>
impl<K, V> IntoWasmAbi for Map<K, V>
type Abi = <JsValue as IntoWasmAbi>::Abi;fn into_abi(self) -> Self::Abi
impl<K, V> Iterable for Map<K, V>
type Item = ArrayTuple<(K, V)>;
impl<K, V> JsCast for Map<K, V>
fn instanceof(val: &JsValue) -> boolfn unchecked_from_js(val: JsValue) -> Selffn unchecked_from_js_ref(val: &JsValue) -> &Self
impl<K, V> LongRefFromWasmAbi for Map<K, V>
type Abi = <JsValue as LongRefFromWasmAbi>::Abi;type Anchor = Map<K, V>;unsafe fn long_ref_from_abi(js: Self::Abi) -> Self::Anchor
impl<K, V> OptionFromWasmAbi for Map<K, V>
fn is_none(abi: &Self::Abi) -> bool
impl<K, V> OptionIntoWasmAbi for Map<K, V>
fn none() -> Self::Abi
impl<K, V> Promising for Map<K, V>
type Resolution = Map<K, V>;
impl<K, V> RefFromWasmAbi for Map<K, V>
type Abi = <JsValue as RefFromWasmAbi>::Abi;type Anchor = ManuallyDrop<Map<K, V>>;unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
impl<K, V> WasmDescribe for Map<K, V>
fn describe()
impl<K, V, __UpcastTarget0, __UpcastTarget1> UpcastFrom<Map<K, V>> for Map<__UpcastTarget0, __UpcastTarget1>
where
__UpcastTarget0: UpcastFrom<K>,
__UpcastTarget1: UpcastFrom<V>,
impl<K: Clone, V: Clone> Clone for Map<K, V>
fn clone(&self) -> Self
impl<K: Debug, V: Debug> Debug for Map<K, V>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<K: Eq, V: Eq> Eq for Map<K, V>
impl<K: PartialEq, V: PartialEq> PartialEq for Map<K, V>
fn eq(&self, other: &Self) -> bool