#[repr(transparent)]pub struct Array<T = JsValue> {
pub obj: Object,
pub generics: PhantomData<fn() -> (T,)>,
}Fields§
§obj: Object§generics: PhantomData<fn() -> (T,)>Implementations§
Source§impl Array
impl Array
Sourcepub fn new_with_length(len: u32) -> Array
pub fn new_with_length(len: u32) -> Array
Creates a new array with the specified length (elements are initialized to undefined).
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn new_with_length_typed(len: u32) -> Array<T>
pub fn new_with_length_typed(len: u32) -> Array<T>
Creates a new array with the specified length (elements are initialized to undefined).
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn get_unchecked(&self, index: u32) -> T
pub fn get_unchecked(&self, index: u32) -> T
Retrieves the element at the index (returns undefined if the index is out of range).
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn get_checked(&self, index: u32) -> Option<T>
pub fn get_checked(&self, index: u32) -> Option<T>
Retrieves the element at the index (returns None if the index is out of range,
or if the element is explicitly undefined).
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn set_ref(&self, index: u32, value: &T)where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
pub fn set_ref(&self, index: u32, value: &T)where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Sets the element at the index (auto-enlarges the array if the index is out of range).
Source§impl Array
impl Array
Source§impl Array
impl Array
Sourcepub fn from_iterable<I>(val: &I) -> Result<Array<I::Item>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + Iterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
Result<Array<I::Item>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn from_iterable<I>(val: &I) -> Result<Array<I::Item>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + Iterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
Result<Array<I::Item>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The Array.from() static method creates a new, shallow-copied Array instance
from an array-like or iterable object.
Source§impl<U> Array<U>
impl<U> Array<U>
Sourcepub fn from_iterable_map<I>(
val: &I,
map: &mut dyn FnMut(I::Item, u32) -> Result<U, JsError>,
) -> Result<Array<U>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + Iterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
dyn FnMut(I::Item, u32) -> Result<U, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(I::Item, u32) -> Result<U, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<U>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn from_iterable_map<I>(
val: &I,
map: &mut dyn FnMut(I::Item, u32) -> Result<U, JsError>,
) -> Result<Array<U>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + Iterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
dyn FnMut(I::Item, u32) -> Result<U, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(I::Item, u32) -> Result<U, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<U>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The Array.from() static method with a map function creates a new, shallow-copied
Array instance from an array-like or iterable object, applying the map function
to each value.
Source§impl Array
impl Array
Sourcepub fn from_async<I>(val: &I) -> Result<Promise<Array<I::Item>>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + AsyncIterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
Result<Promise<Array<I::Item>>, JsValue>: ErasableGenericOwn<Result<Promise<Array<JsValue>>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn from_async<I>(val: &I) -> Result<Promise<Array<I::Item>>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + AsyncIterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
Result<Promise<Array<I::Item>>, JsValue>: ErasableGenericOwn<Result<Promise<Array<JsValue>>, JsValue>> + EncodeTypeDef + BatchableResult,
The Array.fromAsync() static method creates a new, shallow-copied Array instance
from an async iterable, iterable or array-like object.
Source§impl Array
impl Array
Sourcepub fn from_async_map<'a, I, R: Promising>(
val: &I,
map: &ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>,
) -> Result<Promise<Array<R::Resolution>>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + AsyncIterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>: ErasableGenericBorrow<ScopedClosure<'static, dyn FnMut(JsValue, u32) -> Result<JsValue, JsError>>>,
Result<Promise<Array<R::Resolution>>, JsValue>: ErasableGenericOwn<Result<Promise<Array<JsValue>>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn from_async_map<'a, I, R: Promising>(
val: &I,
map: &ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>,
) -> Result<Promise<Array<R::Resolution>>, JsValue>where
I: ErasableGenericBorrow<JsValue> + EncodeTypeDef + AsyncIterable,
for<'__wry_bindgen> &'__wry_bindgen I: BinaryEncode,
ScopedClosure<'a, dyn FnMut(I::Item, u32) -> Result<R, JsError>>: ErasableGenericBorrow<ScopedClosure<'static, dyn FnMut(JsValue, u32) -> Result<JsValue, JsError>>>,
Result<Promise<Array<R::Resolution>>, JsValue>: ErasableGenericOwn<Result<Promise<Array<JsValue>>, JsValue>> + EncodeTypeDef + BatchableResult,
The Array.fromAsync() static method with a map function creates a new, shallow-copied
Array instance from an async iterable, iterable or array-like object, applying the map
function to each value.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn concat<U: Upcast<T>>(&self, array: &Array<U>) -> Array<T>where
Array<U>: ErasableGenericBorrow<Array<JsValue>> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen Array<U>: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn concat<U: Upcast<T>>(&self, array: &Array<U>) -> Array<T>where
Array<U>: ErasableGenericBorrow<Array<JsValue>> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen Array<U>: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The concat() method is used to merge two or more arrays. This method
does not change the existing arrays, but instead returns a new array.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn concat_many<U: Upcast<T>>(&self, array: &[Array<U>]) -> Array<T>where
[Array<U>]: ErasableGenericBorrow<[Array<JsValue>]>,
Array<U>: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn concat_many<U: Upcast<T>>(&self, array: &[Array<U>]) -> Array<T>where
[Array<U>]: ErasableGenericBorrow<[Array<JsValue>]>,
Array<U>: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The concat() method is used to merge two or more arrays. This method
does not change the existing arrays, but instead returns a new array.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn fill(&self, value: &T, start: u32, end: u32) -> Array<T>where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn fill(&self, value: &T, start: u32, end: u32) -> Array<T>where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The fill() method fills all the elements of an array from a start index
to an end index with a static value. The end index is not included.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn filter(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> Array<T>where
dyn FnMut(T, u32, Array<T>) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> bool: EncodeTypeDef + BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn filter(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> Array<T>where
dyn FnMut(T, u32, Array<T>) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> bool: EncodeTypeDef + BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The filter() method creates a new array with all elements that pass the
test implemented by the provided function.
Note: Consider using Array::try_filter if the predicate might throw an error.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_filter(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Array<T>, JsValue>where
dyn FnMut(T, u32) -> Result<bool, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<bool, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<bool, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<T>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_filter(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Array<T>, JsValue>where
dyn FnMut(T, u32) -> Result<bool, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<bool, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<bool, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<T>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The filter() method creates a new array with all elements that pass the
test implemented by the provided function. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn find(&self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> Twhere
dyn FnMut(T, u32, Array<T>) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> bool: EncodeTypeDef + BinaryEncode,
T: ErasableGenericOwn<JsValue> + EncodeTypeDef + BatchableResult,
pub fn find(&self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> Twhere
dyn FnMut(T, u32, Array<T>) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> bool: EncodeTypeDef + BinaryEncode,
T: ErasableGenericOwn<JsValue> + EncodeTypeDef + BatchableResult,
The find() method returns the value of the first element in the array that satisfies
the provided testing function. Otherwise undefined is returned.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_find(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Option<T>, JsValue>where
dyn FnMut(T, u32) -> Result<bool, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<bool, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<bool, JsError>: EncodeTypeDef + BinaryEncode,
Result<Option<T>, JsValue>: ErasableGenericOwn<Result<Option<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_find(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Option<T>, JsValue>where
dyn FnMut(T, u32) -> Result<bool, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<bool, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<bool, JsError>: EncodeTypeDef + BinaryEncode,
Result<Option<T>, JsValue>: ErasableGenericOwn<Result<Option<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The find() method returns the value of the first element in the array that satisfies
the provided testing function. Otherwise undefined is returned. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn find_index(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> i32
pub fn find_index( &self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool, ) -> i32
The findIndex() method returns the index of the first element in the array that
satisfies the provided testing function. Otherwise -1 is returned.
Note: Consider using Array::try_find_index if the predicate might throw an error.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn find_last(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> Twhere
dyn FnMut(T, u32, Array<T>) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> bool: EncodeTypeDef + BinaryEncode,
T: ErasableGenericOwn<JsValue> + EncodeTypeDef + BatchableResult,
pub fn find_last(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> Twhere
dyn FnMut(T, u32, Array<T>) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> bool: EncodeTypeDef + BinaryEncode,
T: ErasableGenericOwn<JsValue> + EncodeTypeDef + BatchableResult,
The findLast() method of Array instances iterates the array in reverse order
and returns the value of the first element that satisfies the provided testing function.
If no elements satisfy the testing function, undefined is returned.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_find_last(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Option<T>, JsValue>where
dyn FnMut(T, u32) -> Result<bool, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<bool, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<bool, JsError>: EncodeTypeDef + BinaryEncode,
Result<Option<T>, JsValue>: ErasableGenericOwn<Result<Option<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_find_last(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Option<T>, JsValue>where
dyn FnMut(T, u32) -> Result<bool, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<bool, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<bool, JsError>: EncodeTypeDef + BinaryEncode,
Result<Option<T>, JsValue>: ErasableGenericOwn<Result<Option<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The findLast() method of Array instances iterates the array in reverse order
and returns the value of the first element that satisfies the provided testing function.
If no elements satisfy the testing function, undefined is returned. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn find_last_index(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> i32
pub fn find_last_index( &self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool, ) -> i32
The findLastIndex() method of Array instances iterates the array in reverse order
and returns the index of the first element that satisfies the provided testing function.
If no elements satisfy the testing function, -1 is returned.
Note: Consider using Array::try_find_last_index if the predicate might throw an error.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_find_last_index(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<i32, JsValue>
pub fn try_find_last_index( &self, predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>, ) -> Result<i32, JsValue>
The findLastIndex() method of Array instances iterates the array in reverse order
and returns the index of the first element that satisfies the provided testing function.
If no elements satisfy the testing function, -1 is returned. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn flat_map<U>(
&self,
callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
) -> Array<U>where
dyn FnMut(T, u32, Array<T>) -> Vec<U>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> Vec<JsValue>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> Vec<U>: EncodeTypeDef + BinaryEncode,
Array<U>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn flat_map<U>(
&self,
callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
) -> Array<U>where
dyn FnMut(T, u32, Array<T>) -> Vec<U>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> Vec<JsValue>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> Vec<U>: EncodeTypeDef + BinaryEncode,
Array<U>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The flatMap() method first maps each element using a mapping function, then flattens
the result into a new array.
Note: Consider using Array::try_flat_map for safer fallible handling.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_flat_map<U>(
&self,
callback: &mut dyn FnMut(T, u32) -> Vec<U>,
) -> Result<Array<U>, JsValue>where
dyn FnMut(T, u32) -> Vec<U>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Vec<JsValue>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Vec<U>: EncodeTypeDef + BinaryEncode,
Result<Array<U>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_flat_map<U>(
&self,
callback: &mut dyn FnMut(T, u32) -> Vec<U>,
) -> Result<Array<U>, JsValue>where
dyn FnMut(T, u32) -> Vec<U>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Vec<JsValue>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Vec<U>: EncodeTypeDef + BinaryEncode,
Result<Array<U>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The flatMap() method first maps each element using a mapping function, then flattens
the result into a new array.
Source§impl<T: JsGeneric> Array<T>
impl<T: JsGeneric> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn includes(&self, value: &T, from_index: i32) -> boolwhere
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
pub fn includes(&self, value: &T, from_index: i32) -> boolwhere
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
The includes() method determines whether an array includes a certain
element, returning true or false as appropriate.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
pub fn index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
The indexOf() method returns the first index at which a given element
can be found in the array, or -1 if it is not present.
Source§impl Array
impl Array
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn last_index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
pub fn last_index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
The lastIndexOf() method returns the last index at which a given element
can be found in the array, or -1 if it is not present. The array is
searched backwards, starting at fromIndex.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn set_length(&self, value: u32)
pub fn set_length(&self, value: u32)
Sets the length of the array.
If it is set to less than the current length of the array, it will shrink the array.
If it is set to more than the current length of the array, it will increase the length of the array, filling the new space with empty slots.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn map<U>(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> U,
) -> Array<U>where
dyn FnMut(T, u32, Array<T>) -> U: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> JsValue>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> U: EncodeTypeDef + BinaryEncode,
Array<U>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn map<U>(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> U,
) -> Array<U>where
dyn FnMut(T, u32, Array<T>) -> U: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32, Array<JsValue>) -> JsValue>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32, Array<T>) -> U: EncodeTypeDef + BinaryEncode,
Array<U>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
map() calls a provided callback function once for each element in an array,
in order, and constructs a new array from the results. callback is invoked
only for indexes of the array which have assigned values, including undefined.
It is not called for missing elements of the array (that is, indexes that have
never been set, which have been deleted or which have never been assigned a value).
Note: Consider using Array::try_map for safer fallible handling.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_map<U>(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
) -> Result<Array<U>, JsValue>where
dyn FnMut(T, u32) -> Result<U, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<U, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<U>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_map<U>(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
) -> Result<Array<U>, JsValue>where
dyn FnMut(T, u32) -> Result<U, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, u32) -> Result<U, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<U>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
map() calls a provided callback function once for each element in an array,
in order, and constructs a new array from the results. callback is invoked
only for indexes of the array which have assigned values, including undefined.
It is not called for missing elements of the array (that is, indexes that have
never been set, which have been deleted or which have never been assigned a value).
(Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn of(values: &[T]) -> Array<T>where
[T]: ErasableGenericBorrow<[JsValue]>,
T: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn of(values: &[T]) -> Array<T>where
[T]: ErasableGenericBorrow<[JsValue]>,
T: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The Array.of() method creates a new Array instance with a variable
number of arguments, regardless of number or type of the arguments.
Note: For type inference use Array::<T>::of(&[T]).
The difference between Array.of() and the Array constructor is in the
handling of integer arguments: Array.of(7) creates an array with a single
element, 7, whereas Array(7) creates an empty array with a length
property of 7 (Note: this implies an array of 7 empty slots, not slots
with actual undefined values).
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn pop(&self) -> T
pub fn pop(&self) -> T
The pop() method removes the last element from an array and returns that
element. This method changes the length of the array.
Note: Consider using Array::pop_checked for handling empty arrays.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn pop_checked(&self) -> Option<T>
pub fn pop_checked(&self) -> Option<T>
The pop() method removes the last element from an array and returns that
element. This method changes the length of the array.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn push(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
pub fn push(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
The push() method adds one element to the end of an array and
returns the new length of the array.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_reduce<A>(
&self,
predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
initial_value: &A,
) -> Result<A, JsValue>where
dyn FnMut(A, T, u32) -> Result<A, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(A, T, u32) -> Result<A, JsError>: EncodeTypeDef + BinaryEncode,
A: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen A: BinaryEncode,
Result<A, JsValue>: ErasableGenericOwn<Result<JsValue, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_reduce<A>(
&self,
predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
initial_value: &A,
) -> Result<A, JsValue>where
dyn FnMut(A, T, u32) -> Result<A, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(A, T, u32) -> Result<A, JsError>: EncodeTypeDef + BinaryEncode,
A: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen A: BinaryEncode,
Result<A, JsValue>: ErasableGenericOwn<Result<JsValue, JsValue>> + EncodeTypeDef + BatchableResult,
The reduce() method applies a function against an accumulator and each element in
the array (from left to right) to reduce it to a single value. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_reduce_right<A>(
&self,
predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
initial_value: &A,
) -> Result<A, JsValue>where
dyn FnMut(JsValue, T, u32) -> Result<A, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>: EncodeTypeDef + BinaryEncode,
A: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen A: BinaryEncode,
Result<A, JsValue>: ErasableGenericOwn<Result<JsValue, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_reduce_right<A>(
&self,
predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
initial_value: &A,
) -> Result<A, JsValue>where
dyn FnMut(JsValue, T, u32) -> Result<A, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue, u32) -> Result<JsValue, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>: EncodeTypeDef + BinaryEncode,
A: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen A: BinaryEncode,
Result<A, JsValue>: ErasableGenericOwn<Result<JsValue, JsValue>> + EncodeTypeDef + BatchableResult,
The reduceRight() method applies a function against an accumulator and each value
of the array (from right-to-left) to reduce it to a single value. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn shift(&self) -> T
pub fn shift(&self) -> T
The shift() method removes the first element from an array and returns
that removed element. This method changes the length of the array.
Note: Consider using Array::shift_checked for handling empty arrays.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn shift_checked(&self) -> Option<T>
pub fn shift_checked(&self) -> Option<T>
The shift() method removes the first element from an array and returns
that removed element. This method changes the length of the array.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn slice_from(&self, start: u32) -> Array<T>
pub fn slice_from(&self, start: u32) -> Array<T>
The slice() method returns a shallow copy of a portion of an array into
a new array object selected from the given index to the end.
The original array will not be modified.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn some(&self, predicate: &mut dyn FnMut(T) -> bool) -> boolwhere
dyn FnMut(T) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T) -> bool: EncodeTypeDef + BinaryEncode,
pub fn some(&self, predicate: &mut dyn FnMut(T) -> bool) -> boolwhere
dyn FnMut(T) -> bool: ErasableGenericBorrowMut<dyn FnMut(JsValue) -> bool>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T) -> bool: EncodeTypeDef + BinaryEncode,
The some() method tests whether at least one element in the array passes the test implemented
by the provided function.
Note: This method returns false for any condition put on an empty array.
Note: Consider using Array::try_some if the predicate might throw an error.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_some(
&self,
predicate: &mut dyn FnMut(T) -> Result<bool, JsError>,
) -> Result<bool, JsValue>
pub fn try_some( &self, predicate: &mut dyn FnMut(T) -> Result<bool, JsError>, ) -> Result<bool, JsValue>
The some() method tests whether at least one element in the array passes the test implemented
by the provided function. (Fallible variation)
Note: This method returns false for any condition put on an empty array.
MDN documentation
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn sort(&self) -> Array<T>
pub fn sort(&self) -> Array<T>
The sort() method sorts the elements of an array in place and returns
the array. The sort is not necessarily stable. The default sort
order is according to string Unicode code points.
The time and space complexity of the sort cannot be guaranteed as it is implementation dependent.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn sort_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>where
dyn FnMut(T, T) -> i32: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> i32>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> i32: EncodeTypeDef + BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn sort_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>where
dyn FnMut(T, T) -> i32: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> i32>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> i32: EncodeTypeDef + BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The sort() method with a custom compare function.
Note: Consider using Array::try_sort_by if the predicate might throw an error.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_sort_by(
&self,
compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
) -> Result<Array<T>, JsValue>where
dyn FnMut(T, T) -> Result<i32, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> Result<i32, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> Result<i32, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<T>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_sort_by(
&self,
compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
) -> Result<Array<T>, JsValue>where
dyn FnMut(T, T) -> Result<i32, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> Result<i32, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> Result<i32, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<T>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The sort() method with a custom compare function. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn splice(&self, start: u32, delete_count: u32, item: &T) -> Array<T>where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn splice(&self, start: u32, delete_count: u32, item: &T) -> Array<T>where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The splice() method changes the contents of an array by removing existing elements and/or
adding new elements.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn splice_many(
&self,
start: u32,
delete_count: u32,
items: &[T],
) -> Array<T>where
[T]: ErasableGenericBorrow<[JsValue]>,
T: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn splice_many(
&self,
start: u32,
delete_count: u32,
items: &[T],
) -> Array<T>where
[T]: ErasableGenericBorrow<[JsValue]>,
T: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The splice() method changes the contents of an array by removing existing elements and/or
adding new elements.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn to_locale_string(&self, locales: &JsValue, options: &JsValue) -> JsString
pub fn to_locale_string(&self, locales: &JsValue, options: &JsValue) -> JsString
The toLocaleString() method returns a string representing the elements of the array.
The elements are converted to Strings using their toLocaleString methods and these
Strings are separated by a locale-specific String (such as a comma “,”).
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn to_reversed(&self) -> Array<T>
pub fn to_reversed(&self) -> Array<T>
The toReversed() method returns a new array with the elements in reversed order,
without modifying the original array.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn to_sorted_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>where
dyn FnMut(T, T) -> i32: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> i32>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> i32: EncodeTypeDef + BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn to_sorted_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>where
dyn FnMut(T, T) -> i32: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> i32>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> i32: EncodeTypeDef + BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The toSorted() method with a custom compare function.
Note: Consider using Array::try_to_sorted_by if the predicate might throw an error.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn try_to_sorted_by(
&self,
compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
) -> Result<Array<T>, JsValue>where
dyn FnMut(T, T) -> Result<i32, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> Result<i32, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> Result<i32, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<T>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
pub fn try_to_sorted_by(
&self,
compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
) -> Result<Array<T>, JsValue>where
dyn FnMut(T, T) -> Result<i32, JsError>: ErasableGenericBorrowMut<dyn FnMut(JsValue, JsValue) -> Result<i32, JsError>>,
for<'__wry_bindgen> &'__wry_bindgen mut dyn FnMut(T, T) -> Result<i32, JsError>: EncodeTypeDef + BinaryEncode,
Result<Array<T>, JsValue>: ErasableGenericOwn<Result<Array<JsValue>, JsValue>> + EncodeTypeDef + BatchableResult,
The toSorted() method with a custom compare function. (Fallible variation)
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn to_spliced(&self, start: u32, delete_count: u32, items: &[T]) -> Array<T>where
[T]: ErasableGenericBorrow<[JsValue]>,
T: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn to_spliced(&self, start: u32, delete_count: u32, items: &[T]) -> Array<T>where
[T]: ErasableGenericBorrow<[JsValue]>,
T: EncodeTypeDef + JsGeneric,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The toSpliced() method returns a new array with some elements removed and/or
replaced at a given index, without modifying the original array.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn unshift(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
pub fn unshift(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
The unshift() method adds one element to the beginning of an
array and returns the new length of the array.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn unshift_many(&self, values: &[T]) -> u32
pub fn unshift_many(&self, values: &[T]) -> u32
The unshift() method adds one or more elements to the beginning of an
array and returns the new length of the array.
Source§impl<T> Array<T>
impl<T> Array<T>
Sourcepub fn with(&self, index: u32, value: &T) -> Array<T>where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
pub fn with(&self, index: u32, value: &T) -> Array<T>where
T: ErasableGenericBorrow<JsValue> + EncodeTypeDef,
for<'__wry_bindgen> &'__wry_bindgen T: BinaryEncode,
Array<T>: ErasableGenericOwn<Array<JsValue>> + EncodeTypeDef + BatchableResult,
The with() method returns a new array with the element at the given index
replaced with the given value, without modifying the original array.
Source§impl<T: JsGeneric> Array<T>
impl<T: JsGeneric> Array<T>
Sourcepub fn from_iter_typed<A, I>(iter: I) -> Array<T>where
A: IntoJsGeneric<JsCanon = T>,
I: IntoIterator<Item = A>,
pub fn from_iter_typed<A, I>(iter: I) -> Array<T>where
A: IntoJsGeneric<JsCanon = T>,
I: IntoIterator<Item = A>,
Collect an iterator into a typed Array<T>, projecting each item
through its canonical JsGeneric via IntoJsGeneric.
This is the typed counterpart to the stable
impl FromIterator<A> for Array where A: AsRef<JsValue>, which always
produces an erased Array<JsValue>. Use from_iter_typed when you
want the element type inferred from the iterator item:
use js_sys::{Array, Number};
let arr = Array::from_iter_typed((0..10).map(Number::from));
// arr: Array<Number>Reference iteration (Item = &U) is supported transparently via the
&U: IntoJsGeneric blanket in wasm-bindgen core.
Sourcepub fn extend_typed<A, I>(&mut self, iter: I)where
A: IntoJsGeneric<JsCanon = T>,
I: IntoIterator<Item = A>,
pub fn extend_typed<A, I>(&mut self, iter: I)where
A: IntoJsGeneric<JsCanon = T>,
I: IntoIterator<Item = A>,
Extend a typed Array<T> with an iterator of items convertible to
T via IntoJsGeneric. Companion to Array::from_iter_typed.
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T> Array<T>
impl<T> Array<T>
Source§impl<T: JsGeneric> Array<T>
impl<T: JsGeneric> Array<T>
Sourcepub fn entries_typed(&self) -> Iterator<ArrayTuple<(Number, T)>>where
Iterator<ArrayTuple<(Number, T)>>: ErasableGenericOwn<Iterator<ArrayTuple<(Number, JsValue)>>> + EncodeTypeDef + BatchableResult,
pub fn entries_typed(&self) -> Iterator<ArrayTuple<(Number, T)>>where
Iterator<ArrayTuple<(Number, T)>>: ErasableGenericOwn<Iterator<ArrayTuple<(Number, JsValue)>>> + EncodeTypeDef + BatchableResult,
The entries() method returns a new Array Iterator object that contains
the key/value pairs for each index in the array.
Methods from Deref<Target = Object>§
Sourcepub fn constructor(&self) -> Function
pub fn constructor(&self) -> Function
The constructor property returns a reference to the Object constructor
function that created the instance object.
Sourcepub fn has_own_property(&self, property: &JsValue) -> bool
👎Deprecated: Use Object::hasOwn instead.
pub fn has_own_property(&self, property: &JsValue) -> bool
Use Object::hasOwn instead.
The hasOwnProperty() method returns a boolean indicating whether the
object has the specified property as its own property (as opposed to
inheriting it).
Sourcepub fn is_prototype_of(&self, value: &JsValue) -> bool
pub fn is_prototype_of(&self, value: &JsValue) -> bool
The isPrototypeOf() method checks if an object exists in another
object’s prototype chain.
Sourcepub fn property_is_enumerable(&self, property: &JsValue) -> bool
pub fn property_is_enumerable(&self, property: &JsValue) -> bool
The propertyIsEnumerable() method returns a Boolean indicating
whether the specified property is enumerable.
Sourcepub fn to_locale_string(&self) -> JsString
pub fn to_locale_string(&self) -> JsString
The toLocaleString() method returns a string representing the object.
This method is meant to be overridden by derived objects for
locale-specific purposes.
Sourcepub fn to_string(&self) -> JsString
pub fn to_string(&self) -> JsString
The toString() method returns a string representing the object.
Sourcepub fn to_js_string(&self) -> JsString
pub fn to_js_string(&self) -> JsString
The toString() method returns a string representing the object.
Methods from Deref<Target = JsValue>§
pub const NULL: JsValue
pub const UNDEFINED: JsValue
pub const TRUE: JsValue
pub const FALSE: JsValue
Sourcepub fn id(&self) -> u64
pub fn id(&self) -> u64
Get the heap ID for this value.
This is used internally for encoding values to send to JS.
Sourcepub fn unchecked_into_f64(&self) -> f64
pub fn unchecked_into_f64(&self) -> f64
Returns the value as f64 without type checking. Used by serde-wasm-bindgen for numeric conversions.
Sourcepub fn has_type<T>(&self) -> boolwhere
T: JsCast,
pub fn has_type<T>(&self) -> boolwhere
T: JsCast,
Check if this value is an instance of a specific JS type.
Sourcepub fn checked_div(&self, rhs: &JsValue) -> JsValue
pub fn checked_div(&self, rhs: &JsValue) -> JsValue
Checked division.
Sourcepub fn unsigned_shr(&self, rhs: &JsValue) -> u32
pub fn unsigned_shr(&self, rhs: &JsValue) -> u32
Unsigned right shift.
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Check if this value is a function.
Sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Check if this value is undefined.
Sourcepub fn is_null_or_undefined(&self) -> bool
pub fn is_null_or_undefined(&self) -> bool
Check if this value is null or undefined.
Sourcepub fn js_in(&self, obj: &JsValue) -> bool
pub fn js_in(&self, obj: &JsValue) -> bool
Check if this value has a property with the given name.
Sourcepub fn as_debug_string(&self) -> String
pub fn as_debug_string(&self) -> String
Get a debug string representation of the value.
Trait Implementations§
Source§impl AsRef<Array> for RegExpMatchArray
impl AsRef<Array> for RegExpMatchArray
Source§impl<T> BatchableResult for Array<T>
impl<T> BatchableResult for Array<T>
Source§impl<T> BinaryDecode for Array<T>
impl<T> BinaryDecode for Array<T>
fn decode(decoder: &mut DecodedData<'_>) -> Result<Self, DecodeError>
Source§impl<T> BinaryEncode for Array<T>
impl<T> BinaryEncode for Array<T>
fn encode(self, encoder: &mut EncodedData)
Source§impl<T> EncodeTypeDef for Array<T>
impl<T> EncodeTypeDef for Array<T>
Source§fn encode_type_def(buf: &mut Vec<u8>)
fn encode_type_def(buf: &mut Vec<u8>)
Source§impl<A> Extend<A> for Array
impl<A> Extend<A> for Array
Source§fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = A>,
fn extend<I>(&mut self, iter: I)where
I: IntoIterator<Item = A>,
Source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one)Source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one)Source§impl From<RegExpMatchArray> for Array
impl From<RegExpMatchArray> for Array
Source§fn from(val: RegExpMatchArray) -> Array
fn from(val: RegExpMatchArray) -> Array
Source§impl<A> FromIterator<A> for Array
impl<A> FromIterator<A> for Array
Source§impl<T: JsGeneric> IntoIterator for Array<T>
impl<T: JsGeneric> IntoIterator for Array<T>
Source§impl<T: 'static> IntoJsGeneric for Array<T>
impl<T: 'static> IntoJsGeneric for Array<T>
Source§impl<T> JsCast for Array<T>
impl<T> JsCast for Array<T>
Source§fn instanceof(__val: &JsValue) -> bool
fn instanceof(__val: &JsValue) -> bool
Source§fn is_type_of(__val: &JsValue) -> bool
fn is_type_of(__val: &JsValue) -> bool
JsValue provided
is a value of this type. Read moreSource§fn unchecked_from_js(val: JsValue) -> Self
fn unchecked_from_js(val: JsValue) -> Self
Source§fn unchecked_from_js_ref(val: &JsValue) -> &Self
fn unchecked_from_js_ref(val: &JsValue) -> &Self
Source§fn has_type<T>(&self) -> boolwhere
T: JsCast,
fn has_type<T>(&self) -> boolwhere
T: JsCast,
T. Read moreSource§fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self>where
T: JsCast,
Source§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
Source§fn is_instance_of<T>(&self) -> boolwhere
T: JsCast,
fn is_instance_of<T>(&self) -> boolwhere
T: JsCast,
T. Read more