pub struct SpawnArgs { /* private fields */ }Methods from Deref<Target = Array>§
Sourcepub fn at(&self, index: i32) -> Twhere
T: ErasableGenericOwn<JsValue>,
pub fn at(&self, index: i32) -> Twhere
T: ErasableGenericOwn<JsValue>,
Retrieves the element at the index, counting from the end if negative
(returns undefined if the index is out of range).
Sourcepub fn get(&self, index: u32) -> Twhere
T: ErasableGenericOwn<JsValue>,
pub fn get(&self, index: u32) -> Twhere
T: ErasableGenericOwn<JsValue>,
Retrieves the element at the index (returns undefined if the index is out of range).
Sourcepub fn get_unchecked(&self, index: u32) -> Twhere
T: ErasableGenericOwn<JsValue>,
pub fn get_unchecked(&self, index: u32) -> Twhere
T: ErasableGenericOwn<JsValue>,
Retrieves the element at the index (returns undefined if the index is out of range).
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).
Sourcepub fn set(&self, index: u32, value: T)where
T: ErasableGenericOwn<JsValue>,
pub fn set(&self, index: u32, value: T)where
T: ErasableGenericOwn<JsValue>,
Sets the element at the index (auto-enlarges the array if the index is out of range).
Sourcepub fn set_ref(&self, index: u32, value: &T)where
T: ErasableGenericBorrow<JsValue>,
pub fn set_ref(&self, index: u32, value: &T)where
T: ErasableGenericBorrow<JsValue>,
Sets the element at the index (auto-enlarges the array if the index is out of range).
Sourcepub fn delete(&self, index: u32)
pub fn delete(&self, index: u32)
Deletes the element at the index (does nothing if the index is out of range).
The element at the index is set to undefined.
This does not resize the array, the array will still be the same length.
Sourcepub fn copy_within(&self, target: i32, start: i32, end: i32) -> Array<T>
pub fn copy_within(&self, target: i32, start: i32, end: i32) -> Array<T>
The copyWithin() method shallow copies part of an array to another
location in the same array and returns it, without modifying its size.
Sourcepub fn concat<U>(&self, array: &Array<U>) -> Array<T>
pub fn concat<U>(&self, array: &Array<U>) -> Array<T>
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.
Sourcepub fn concat_many<U>(&self, array: &[Array<U>]) -> Array<T>
pub fn concat_many<U>(&self, array: &[Array<U>]) -> Array<T>
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.
Sourcepub fn every(&self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> bool
pub fn every(&self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> bool
The every() method tests whether all elements in the array pass the test
implemented by the provided function.
Note: Consider using Array::try_every if the predicate might throw an error.
Sourcepub fn try_every(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<bool, JsValue>
pub fn try_every( &self, predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>, ) -> Result<bool, JsValue>
The every() method tests whether all elements in the array pass the test
implemented by the provided function. (Fallible variation)
Sourcepub fn fill(&self, value: &T, start: u32, end: u32) -> Array<T>
pub fn fill(&self, value: &T, start: u32, end: u32) -> Array<T>
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.
Sourcepub fn filter(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> Array<T>
pub fn filter( &self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool, ) -> Array<T>
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.
Sourcepub fn try_filter(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Array<T>, JsValue>
pub fn try_filter( &self, predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>, ) -> Result<Array<T>, JsValue>
The filter() method creates a new array with all elements that pass the
test implemented by the provided function. (Fallible variation)
Sourcepub fn find(&self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T
pub fn find(&self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool) -> T
The find() method returns the value of the first element in the array that satisfies
the provided testing function. Otherwise undefined is returned.
Sourcepub fn try_find(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Option<T>, JsValue>
pub fn try_find( &self, predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>, ) -> Result<Option<T>, JsValue>
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)
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.
Sourcepub fn try_find_index(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<i32, JsValue>
pub fn try_find_index( &self, predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>, ) -> Result<i32, JsValue>
The findIndex() method returns the index of the first element in the array that
satisfies the provided testing function. Otherwise -1 is returned. (Fallible variation)
Sourcepub fn find_last(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool,
) -> T
pub fn find_last( &self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> bool, ) -> T
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.
Sourcepub fn try_find_last(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>,
) -> Result<Option<T>, JsValue>
pub fn try_find_last( &self, predicate: &mut dyn FnMut(T, u32) -> Result<bool, JsError>, ) -> Result<Option<T>, JsValue>
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)
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.
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)
Sourcepub fn flat(&self, depth: i32) -> Array
pub fn flat(&self, depth: i32) -> Array
The flat() method creates a new array with all sub-array elements concatenated into it
recursively up to the specified depth.
Sourcepub fn flat_map<U>(
&self,
callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>,
) -> Array<U>
pub fn flat_map<U>( &self, callback: &mut dyn FnMut(T, u32, Array<T>) -> Vec<U>, ) -> Array<U>
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.
Sourcepub fn try_flat_map<U>(
&self,
callback: &mut dyn FnMut(T, u32) -> Vec<U>,
) -> Result<Array<U>, JsValue>
pub fn try_flat_map<U>( &self, callback: &mut dyn FnMut(T, u32) -> Vec<U>, ) -> Result<Array<U>, JsValue>
The flatMap() method first maps each element using a mapping function, then flattens
the result into a new array.
Sourcepub fn for_each(&self, callback: &mut dyn FnMut(T, u32, Array<T>))
pub fn for_each(&self, callback: &mut dyn FnMut(T, u32, Array<T>))
The forEach() method executes a provided function once for each array element.
Note: Consider using Array::try_for_each if the callback might throw an error.
Sourcepub fn try_for_each(
&self,
callback: &mut dyn FnMut(T, u32) -> Result<(), JsError>,
) -> Result<(), JsValue>
pub fn try_for_each( &self, callback: &mut dyn FnMut(T, u32) -> Result<(), JsError>, ) -> Result<(), JsValue>
The forEach() method executes a provided function once for each array element. (Fallible variation)
Sourcepub fn includes(&self, value: &T, from_index: i32) -> boolwhere
T: ErasableGenericBorrow<JsValue>,
pub fn includes(&self, value: &T, from_index: i32) -> boolwhere
T: ErasableGenericBorrow<JsValue>,
The includes() method determines whether an array includes a certain
element, returning true or false as appropriate.
Sourcepub fn index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue>,
pub fn index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue>,
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.
Sourcepub fn join(&self, delimiter: &str) -> JsString
pub fn join(&self, delimiter: &str) -> JsString
The join() method joins all elements of an array (or an array-like object)
into a string and returns this string.
Sourcepub fn last_index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue>,
pub fn last_index_of(&self, value: &T, from_index: i32) -> i32where
T: ErasableGenericBorrow<JsValue>,
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.
Sourcepub fn length(&self) -> u32
pub fn length(&self) -> u32
The length property of an object which is an instance of type Array sets or returns the number of elements in that array. The value is an unsigned, 32-bit integer that is always numerically greater than the highest index in the array.
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.
Sourcepub fn map<U>(
&self,
predicate: &mut dyn FnMut(T, u32, Array<T>) -> U,
) -> Array<U>
pub fn map<U>( &self, predicate: &mut dyn FnMut(T, u32, Array<T>) -> U, ) -> Array<U>
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.
Sourcepub fn try_map<U>(
&self,
predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>,
) -> Result<Array<U>, JsValue>
pub fn try_map<U>( &self, predicate: &mut dyn FnMut(T, u32) -> Result<U, JsError>, ) -> Result<Array<U>, JsValue>
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)
Sourcepub fn pop(&self) -> Twhere
T: ErasableGenericOwn<JsValue>,
pub fn pop(&self) -> Twhere
T: ErasableGenericOwn<JsValue>,
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.
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.
Sourcepub fn push(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue>,
pub fn push(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue>,
The push() method adds one element to the end of an array and
returns the new length of the array.
Sourcepub fn push_many(&self, values: &[T]) -> u32
pub fn push_many(&self, values: &[T]) -> u32
The push() method adds one or more elements to the end of an array and
returns the new length of the array.
Sourcepub fn reduce(
&self,
predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
initial_value: &JsValue,
) -> JsValue
pub fn reduce( &self, predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue, initial_value: &JsValue, ) -> JsValue
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.
Sourcepub fn try_reduce<A>(
&self,
predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>,
initial_value: &A,
) -> Result<A, JsValue>
pub fn try_reduce<A>( &self, predicate: &mut dyn FnMut(A, T, u32) -> Result<A, JsError>, initial_value: &A, ) -> Result<A, JsValue>
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)
Sourcepub fn reduce_right(
&self,
predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue,
initial_value: &JsValue,
) -> JsValue
pub fn reduce_right( &self, predicate: &mut dyn FnMut(JsValue, T, u32, Array<T>) -> JsValue, initial_value: &JsValue, ) -> JsValue
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.
Sourcepub fn try_reduce_right<A>(
&self,
predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>,
initial_value: &A,
) -> Result<A, JsValue>
pub fn try_reduce_right<A>( &self, predicate: &mut dyn FnMut(JsValue, T, u32) -> Result<A, JsError>, initial_value: &A, ) -> Result<A, JsValue>
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)
Sourcepub fn reverse(&self) -> Array<T>
pub fn reverse(&self) -> Array<T>
The reverse() method reverses an array in place. The first array
element becomes the last, and the last array element becomes the first.
Sourcepub fn shift(&self) -> Twhere
T: ErasableGenericOwn<JsValue>,
pub fn shift(&self) -> Twhere
T: ErasableGenericOwn<JsValue>,
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.
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.
Sourcepub fn slice(&self, start: u32, end: u32) -> Array<T>
pub fn slice(&self, start: u32, end: u32) -> Array<T>
The slice() method returns a shallow copy of a portion of an array into
a new array object selected from begin to end (end not included).
The original array will not be modified.
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.
Sourcepub fn some(&self, predicate: &mut dyn FnMut(T) -> bool) -> bool
pub fn some(&self, predicate: &mut dyn FnMut(T) -> bool) -> bool
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.
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
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.
Sourcepub fn sort_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>
pub fn sort_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>
The sort() method with a custom compare function.
Note: Consider using Array::try_sort_by if the predicate might throw an error.
Sourcepub fn try_sort_by(
&self,
compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
) -> Result<Array<T>, JsValue>
pub fn try_sort_by( &self, compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>, ) -> Result<Array<T>, JsValue>
The sort() method with a custom compare function. (Fallible variation)
Sourcepub fn splice(&self, start: u32, delete_count: u32, item: &T) -> Array<T>
pub fn splice(&self, start: u32, delete_count: u32, item: &T) -> Array<T>
The splice() method changes the contents of an array by removing existing elements and/or
adding new elements.
Sourcepub fn splice_many(
&self,
start: u32,
delete_count: u32,
items: &[T],
) -> Array<T>
pub fn splice_many( &self, start: u32, delete_count: u32, items: &[T], ) -> Array<T>
The splice() method changes the contents of an array by removing existing elements and/or
adding new elements.
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 “,”).
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.
Sourcepub fn to_sorted(&self) -> Array<T>
pub fn to_sorted(&self) -> Array<T>
The toSorted() method returns a new array with the elements sorted in ascending order,
without modifying the original array.
Sourcepub fn to_sorted_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>
pub fn to_sorted_by(&self, compare_fn: &mut dyn FnMut(T, T) -> i32) -> Array<T>
The toSorted() method with a custom compare function.
Note: Consider using Array::try_to_sorted_by if the predicate might throw an error.
Sourcepub fn try_to_sorted_by(
&self,
compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>,
) -> Result<Array<T>, JsValue>
pub fn try_to_sorted_by( &self, compare_fn: &mut dyn FnMut(T, T) -> Result<i32, JsError>, ) -> Result<Array<T>, JsValue>
The toSorted() method with a custom compare function. (Fallible variation)
Sourcepub fn to_spliced(&self, start: u32, delete_count: u32, items: &[T]) -> Array<T>
pub fn to_spliced(&self, start: u32, delete_count: u32, items: &[T]) -> Array<T>
The toSpliced() method returns a new array with some elements removed and/or
replaced at a given index, without modifying the original array.
Sourcepub fn to_string(&self) -> JsString
pub fn to_string(&self) -> JsString
The toString() method returns a string representing the specified array
and its elements.
Sourcepub fn unshift(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue>,
pub fn unshift(&self, value: &T) -> u32where
T: ErasableGenericBorrow<JsValue>,
The unshift() method adds one element to the beginning of an
array and returns the new length of the array.
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.
Sourcepub fn with(&self, index: u32, value: &T) -> Array<T>
pub fn with(&self, index: u32, value: &T) -> Array<T>
The with() method returns a new array with the element at the given index
replaced with the given value, without modifying the original array.
Sourcepub fn keys(&self) -> Iterator<T>
pub fn keys(&self) -> Iterator<T>
The keys() method returns a new Array Iterator object that contains the
keys for each index in the array.
Sourcepub fn entries(&self) -> Iterator<T>
👎Deprecated: recommended to use Array::entries_typed instead for typing
pub fn entries(&self) -> Iterator<T>
recommended to use Array::entries_typed instead for typing
The entries() method returns a new Array Iterator object that contains
the key/value pairs for each index in the array.
Sourcepub fn entries_typed(&self) -> Iterator<ArrayTuple<(Number, T)>>where
Iterator<ArrayTuple<(Number, T)>>: ErasableGenericOwn<Iterator<ArrayTuple<(Number, JsValue)>>>,
pub fn entries_typed(&self) -> Iterator<ArrayTuple<(Number, T)>>where
Iterator<ArrayTuple<(Number, T)>>: ErasableGenericOwn<Iterator<ArrayTuple<(Number, JsValue)>>>,
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 as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the f64 value of this JS value if it’s an instance of a
number.
If this JS value is not an instance of a number then this returns
None.
Sourcepub fn as_string(&self) -> Option<String>
pub fn as_string(&self) -> Option<String>
If this JS value is a string value, this function copies the JS string
value into Wasm linear memory, encoded as UTF-8, and returns it as a
Rust String.
To avoid the copying and re-encoding, consider the
JsString::try_from() function from js-sys
instead.
If this JS value is not an instance of a string or if it’s not valid
utf-8 then this returns None.
§UTF-16 vs UTF-8
JavaScript strings in general are encoded as UTF-16, but Rust strings
are encoded as UTF-8. This can cause the Rust string to look a bit
different than the JS string sometimes. For more details see the
documentation about the str type which contains a few
caveats about the encodings.
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the bool value of this JS value if it’s an instance of a
boolean.
If this JS value is not an instance of a boolean then this returns
None.
Sourcepub fn is_undefined(&self) -> bool
pub fn is_undefined(&self) -> bool
Tests whether this JS value is undefined
Sourcepub fn is_null_or_undefined(&self) -> bool
pub fn is_null_or_undefined(&self) -> bool
Tests whether this JS value is null or undefined
Sourcepub fn is_function(&self) -> bool
pub fn is_function(&self) -> bool
Tests whether the type of this JS value is function.
Sourcepub fn js_in(&self, obj: &JsValue) -> bool
pub fn js_in(&self, obj: &JsValue) -> bool
Applies the binary in JS operator on the two JsValues.
Sourcepub fn loose_eq(&self, other: &JsValue) -> bool
pub fn loose_eq(&self, other: &JsValue) -> bool
Compare two JsValues for equality, using the == operator in JS.
Sourcepub fn unsigned_shr(&self, rhs: &JsValue) -> u32
pub fn unsigned_shr(&self, rhs: &JsValue) -> u32
Applies the binary >>> JS operator on the two JsValues.
Sourcepub fn checked_div(&self, rhs: &JsValue) -> JsValue
pub fn checked_div(&self, rhs: &JsValue) -> JsValue
Applies the binary / JS operator on two JsValues, catching and returning any RangeError thrown.
Sourcepub fn pow(&self, rhs: &JsValue) -> JsValue
pub fn pow(&self, rhs: &JsValue) -> JsValue
Applies the binary ** JS operator on the two JsValues.
Sourcepub fn lt(&self, other: &JsValue) -> bool
pub fn lt(&self, other: &JsValue) -> bool
Applies the binary < JS operator on the two JsValues.
Sourcepub fn le(&self, other: &JsValue) -> bool
pub fn le(&self, other: &JsValue) -> bool
Applies the binary <= JS operator on the two JsValues.
Sourcepub fn ge(&self, other: &JsValue) -> bool
pub fn ge(&self, other: &JsValue) -> bool
Applies the binary >= JS operator on the two JsValues.
Sourcepub fn gt(&self, other: &JsValue) -> bool
pub fn gt(&self, other: &JsValue) -> bool
Applies the binary > JS operator on the two JsValues.
Sourcepub fn unchecked_into_f64(&self) -> f64
pub fn unchecked_into_f64(&self) -> f64
Applies the unary + JS operator on a JsValue. Can throw.
Trait Implementations§
Source§impl ErasableGeneric for SpawnArgs
impl ErasableGeneric for SpawnArgs
Source§impl FromWasmAbi for SpawnArgs
impl FromWasmAbi for SpawnArgs
Source§impl IntoJsGeneric for SpawnArgs
impl IntoJsGeneric for SpawnArgs
Source§impl<'a> IntoWasmAbi for &'a SpawnArgs
impl<'a> IntoWasmAbi for &'a SpawnArgs
Source§impl IntoWasmAbi for SpawnArgs
impl IntoWasmAbi for SpawnArgs
Source§impl JsCast for SpawnArgs
impl JsCast for SpawnArgs
Source§fn instanceof(val: &JsValue) -> bool
fn instanceof(val: &JsValue) -> bool
instanceof check to see whether the JsValue
provided is an instance 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,
T. Read moreSource§fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T>where
T: JsCast,
T. Read moreSource§fn unchecked_into<T>(self) -> Twhere
T: JsCast,
fn unchecked_into<T>(self) -> Twhere
T: JsCast,
Source§fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
fn unchecked_ref<T>(&self) -> &Twhere
T: JsCast,
Source§impl LongRefFromWasmAbi for SpawnArgs
impl LongRefFromWasmAbi for SpawnArgs
Source§impl OptionFromWasmAbi for SpawnArgs
impl OptionFromWasmAbi for SpawnArgs
Source§impl<'a> OptionIntoWasmAbi for &'a SpawnArgs
impl<'a> OptionIntoWasmAbi for &'a SpawnArgs
Source§impl OptionIntoWasmAbi for SpawnArgs
impl OptionIntoWasmAbi for SpawnArgs
Source§impl Promising for SpawnArgs
impl Promising for SpawnArgs
Source§type Resolution = SpawnArgs
type Resolution = SpawnArgs
Source§impl RefFromWasmAbi for SpawnArgs
impl RefFromWasmAbi for SpawnArgs
Source§type Abi = <JsValue as RefFromWasmAbi>::Abi
type Abi = <JsValue as RefFromWasmAbi>::Abi
Self are recovered from.Source§type Anchor = ManuallyDrop<SpawnArgs>
type Anchor = ManuallyDrop<SpawnArgs>
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.impl Eq for SpawnArgs
impl StructuralPartialEq for SpawnArgs
impl UpcastFrom<SpawnArgs> for Array
impl UpcastFrom<SpawnArgs> for JsOption<Array>
impl UpcastFrom<SpawnArgs> for JsOption<SpawnArgs>
impl UpcastFrom<SpawnArgs> for JsValue
impl UpcastFrom<SpawnArgs> for SpawnArgs
Auto Trait Implementations§
impl Freeze for SpawnArgs
impl RefUnwindSafe for SpawnArgs
impl Send for SpawnArgs
impl Sync for SpawnArgs
impl Unpin for SpawnArgs
impl UnsafeUnpin for SpawnArgs
impl UnwindSafe for SpawnArgs
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.Source§impl<T> TryFromJsValue for Twhere
T: JsCast,
impl<T> TryFromJsValue for Twhere
T: JsCast,
Source§impl<S, T> Upcast<T> for S
impl<S, T> Upcast<T> for S
Source§impl<T> VectorFromWasmAbi for Twhere
T: ErasableGeneric<Repr = JsValue> + WasmDescribe,
impl<T> VectorFromWasmAbi for Twhere
T: ErasableGeneric<Repr = JsValue> + WasmDescribe,
Source§impl<T> VectorIntoWasmAbi for Twhere
T: ErasableGeneric<Repr = JsValue> + WasmDescribe,
impl<T> VectorIntoWasmAbi for Twhere
T: ErasableGeneric<Repr = JsValue> + WasmDescribe,
Source§impl<T> VectorRefIntoWasmAbi for T
impl<T> VectorRefIntoWasmAbi for T
Source§fn slice_into_abi(slice: &[T]) -> WasmSlice
fn slice_into_abi(slice: &[T]) -> WasmSlice
Some(slice). The returned
WasmSlice is either a borrow of the input slice (primitive
case) or a buffer JS owns and frees (handle-shaped case).Source§fn slice_none() -> WasmSlicewhere
Self: Sized,
fn slice_none() -> WasmSlicewhere
Self: Sized,
None (used by Option<&[T]>). A null
WasmSlice (ptr == 0) is the convention shared with every
other vector-like ABI in the crate.