[−][src]Struct xterm_js_sys::ReadOnlyArray
Mirrors TypeScript's ReadOnlyArray
interface.
This is built on the Array
type in js-sys
and primarily just
mirrors over the subset of regular array functions that
ReadOnlyArray
provides. This wrapper also offers typed versions of all the
functions that it forwards (prefixed with typed_
).
Because wasm-bindgen
doesn't support generic structs, this type uses
#[repr(transparent)]
and leans on its inner Array
for all the
wasm-bindgen
specific impls.
Note that this struct does not provide an AsRef
impl for Array
as that would defeat the "read only" part of this type's guarantees.
Fields
inner: Array
The Array
we're backed by.
_t: PhantomData<T>
Marker for T
.
Implementations
impl<T: JsCast> ReadOnlyArray<T>
[src]
#[must_use]pub fn get(&self, index: u32) -> JsValue
[src]
Retrieves the element at the index (returns undefined
if the index
is out of range).
#[must_use]pub fn concat(&self, array: &Array) -> Array
[src]
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.
#[must_use]pub fn every(
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> bool
[src]
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> bool
The every()
method tests whether all elements in the array pass
the test implemented by the provided function.
#[must_use]pub fn filter(
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> Array
[src]
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> Array
The filter()
method creates a new array with all elements that
pass the test implemented by the provided function.
#[must_use]pub fn find(
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> JsValue
[src]
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> JsValue
The find()
method returns the value of the first element in the
array that satisfies the provided testing function. Otherwise
undefined
is returned.
#[must_use]pub fn find_index(
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> bool
) -> i32
[src]
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> 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.
#[must_use]pub fn flat(&self, depth: i32) -> Array
[src]
The flat()
method creates a new array with all sub-array elements
concatenated into it recursively up to the specified depth.
#[must_use]pub fn flat_map(
&self,
callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>
) -> Array
[src]
&self,
callback: &mut dyn FnMut(JsValue, u32, Array) -> Vec<JsValue>
) -> Array
The flatMap()
method first maps each element using a mapping
function, then flattens the result into a new array.
pub fn for_each(&self, callback: &mut dyn FnMut(JsValue, u32, Array))
[src]
The forEach()
method executes a provided function once for each
array element.
#[must_use]pub fn includes(&self, value: &JsValue, from_index: i32) -> bool
[src]
The includes()
method determines whether an array includes a
certain element, returning true or false as appropriate.
#[must_use]pub fn index_of(&self, value: &JsValue, from_index: i32) -> i32
[src]
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.
#[must_use]pub fn join(&self, delimiter: &str) -> JsString
[src]
The join()
method joins all elements of an array (or an array-like
object) into a string and returns this string.
#[must_use]pub fn last_index_of(&self, value: &JsValue, from_index: i32) -> i32
[src]
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.
#[must_use]pub fn length(&self) -> u32
[src]
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.
#[must_use]pub fn map(
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue
) -> Array
[src]
&self,
predicate: &mut dyn FnMut(JsValue, u32, Array) -> JsValue
) -> Array
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).
#[must_use]pub fn reduce(
&self,
predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
initial_value: &JsValue
) -> JsValue
[src]
&self,
predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> 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.
#[must_use]pub fn reduce_right(
&self,
predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> JsValue,
initial_value: &JsValue
) -> JsValue
[src]
&self,
predicate: &mut dyn FnMut(JsValue, JsValue, u32, Array) -> 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.
#[must_use]pub fn slice(&self, start: u32, end: u32) -> Array
[src]
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.
Note that because a copy is returned, the fact that an Array
is
produced from a ReadOnlyArray
is not a problem.
#[must_use]pub fn some(&self, predicate: &mut dyn FnMut(JsValue) -> bool) -> bool
[src]
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.
#[must_use]pub fn to_locale_string(&self, locales: &JsValue, options: &JsValue) -> JsString
[src]
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 “,”).
#[must_use]pub fn to_string(&self) -> JsString
[src]
The toString()
method returns a string representing the specified
array and its elements.
#[must_use]pub fn iter(&self) -> ArrayIter<'_>
[src]
Returns an iterator over the values of the JS array.
#[must_use]pub fn to_vec(&self) -> Vec<JsValue>
[src]
Converts the JS array into a new Vec
.
#[must_use]pub fn keys(&self) -> Iterator
[src]
The keys()
method returns a new Array Iterator object that
contains the keys for each index in the array.
#[must_use]pub fn entries(&self) -> Iterator
[src]
The entries()
method returns a new Array Iterator object that
contains the key/value pairs for each index in the array.
#[must_use]pub fn values(&self) -> Iterator
[src]
The values()
method returns a new Array Iterator object that
contains the values for each index in the array.
#[must_use]pub fn is_array(value: &JsValue) -> bool
[src]
The Array.isArray()
method determines whether the passed value is an
Array.
impl<T: JsCast> ReadOnlyArray<T>
[src]
#[must_use]pub fn typed_get(&self, index: u32) -> Option<T>
[src]
Typed version of Array::get
.
Returns None
when the element can't be casted into T
or the index is
out of bounds.
#[must_use]pub fn typed_concat(&self, array: &Self) -> Self
[src]
Typed version of Array::concat
.
pub fn typed_every(&self, predicate: impl FnMut(T, u32, Self) -> bool) -> bool
[src]
Typed version of Array::every
.
Returns false
is any of the elements can't be casted into T
.
#[must_use]pub fn typed_filter(&self, predicate: impl FnMut(T, u32, Self) -> bool) -> Self
[src]
Typed version of Array::filter
.
Elements that can't be casted into T
are automatically filtered out.
#[must_use]pub fn typed_find(
&self,
predicate: impl FnMut(T, u32, Self) -> bool
) -> Option<T>
[src]
&self,
predicate: impl FnMut(T, u32, Self) -> bool
) -> Option<T>
Typed version of Array::find
.
Elements that can't be casted into T
are automatically ignored.
#[must_use]pub fn typed_find_index(
&self,
predicate: impl FnMut(T, u32, Self) -> bool
) -> Option<u32>
[src]
&self,
predicate: impl FnMut(T, u32, Self) -> bool
) -> Option<u32>
Typed version of Array::find_index
.
Elements that can't be casted into T
are automatically ignored.
Returns None
when the element can't be found.
#[must_use]pub fn typed_flat(&self, depth: i32) -> Self
[src]
Typed version of Array::flat
.
#[must_use]pub fn typed_flat_map(
&self,
callback: impl FnMut(T, u32, Self) -> Vec<T>
) -> Self
[src]
&self,
callback: impl FnMut(T, u32, Self) -> Vec<T>
) -> Self
Typed version of Array::flat_map
.
Elements that can't be casted into T
are automatically ignored.
pub fn typed_for_each(&self, callback: impl FnMut(T, u32, Self))
[src]
Typed version of Array::for_each
.
Elements that can't be casted into T
are automatically ignored.
pub fn typed_includes(&self, value: T, from_index: i32) -> bool
[src]
Typed version of Array::includes
.
Note that this takes the element to search for by value (we have no way
to convert from &T
to &JsValue
); if T
impls AsRef<JsValue>
,
you're better off using ReadOnlyArray::includes
; it will be cheaper
(but possibly less ergonomic).
pub fn typed_index_of(&self, value: T, from_index: i32) -> Option<u32>
[src]
Typed version of Array::index_of
.
Note that this takes the element to search for by value (we have no way
to convert from &T
to &JsValue
); if T
impls AsRef<JsValue>
,
you're better off using ReadOnlyArray::index_of
; it will be cheaper
(but possibly less ergonomic).
Returns None
when the element can't be found.
pub fn typed_last_index_of(&self, value: T, from_index: i32) -> Option<u32>
[src]
Typed version of Array::last_index_of
.
Note that this takes the element to search for by value (we have no way
to convert from &T
to &JsValue
); if T
impls AsRef<JsValue>
,
you're better off using ReadOnlyArray::last_index_of
; it will be
cheaper (but possibly less ergonomic).
Returns None
when the element can't be found.
#[must_use]pub fn typed_map<R: JsCast>(
&self,
predicate: impl FnMut(T, u32, Self) -> R
) -> ReadOnlyArray<R>
[src]
&self,
predicate: impl FnMut(T, u32, Self) -> R
) -> ReadOnlyArray<R>
Typed version of Array::map
.
Elements that can't be cast into T
are mapped to
JsValue::UNDEFINED
.
#[must_use]pub fn typed_reduce<A: JsCast>(
&self,
predicate: impl FnMut(A, T, u32, Self) -> A,
initial_value: A
) -> A
[src]
&self,
predicate: impl FnMut(A, T, u32, Self) -> A,
initial_value: A
) -> A
Typed version of Array::reduce
.
Effectively 'skips' elements that can't be cast to T
(just returns the
accumulator as is for those elements).
#[must_use]pub fn typed_reduce_right<A: JsCast>(
&self,
predicate: impl FnMut(A, T, u32, Self) -> A,
initial_value: A
) -> A
[src]
&self,
predicate: impl FnMut(A, T, u32, Self) -> A,
initial_value: A
) -> A
Typed version of Array::reduce_right
.
Effectively 'skips' elements that can't be cast to T
(just returns the
accumulator as is for those elements).
#[must_use]pub fn typed_slice(&self, start: u32, end: u32) -> Self
[src]
Typed version of Array::slice
.
#[must_use]pub fn typed_some(&self, predicate: impl FnMut(T) -> bool) -> bool
[src]
Typed version of Array::some
.
Elements that can't be casted into T
are effectively ignored (false
is returned).
pub fn typed_iter<'a>(&'a self) -> impl Iterator<Item = T> + 'a
[src]
Typed version of Array::iter
.
Elements that can't be casted into T
are omitted.
#[must_use]pub fn typed_to_vec(&self) -> Vec<T>
[src]
Typed version of Array::to_vec
.
Elements that can't be casted into T
are omitted.
pub fn typed_keys(&self) -> impl Iterator<Item = u32>
[src]
Typed version of Array::keys
.
pub fn typed_entries(&self) -> impl Iterator<Item = (u32, Result<T, JsValue>)>
[src]
Typed version of Array::entries
.
Returns Err(JsValue)
s for elements that could not be casted as T
and
elements that would have caused TypeError
s (i.e. non-objects). See
js_sys::Iterator::next
for more details about the latter case.
pub fn typed_values(&self) -> impl Iterator<Item = Result<T, JsValue>>
[src]
Typed version of Array::values
.
Returns Err(JsValue)
s for elements that could not be casted as T
and
elements that would have caused TypeError
s (i.e. non-objects). See
js_sys::Iterator::next
for more details about the latter case.
impl<T: JsCast> ReadOnlyArray<T>
[src]
#[must_use]pub fn mutable_array_copy(&self) -> Array
[src]
Produces a copy of the array that is mutable (i.e. an Array
).
#[must_use]pub fn excluding_other_types(&self) -> Self
[src]
Produces a copy of the array that excludes any elements that can't be
cast as T
.
Indexing into this array (for valid indexes), for example, should always
produce Some(_)
s.
Methods from Deref<Target = Object>
pub fn constructor(&self) -> Function
[src]
feature="ext"
only.The constructor property returns a reference to the Object
constructor
function that created the instance object.
pub fn has_own_property(&self, property: &JsValue) -> bool
[src]
feature="ext"
only.The hasOwnProperty()
method returns a boolean indicating whether the
object has the specified property as its own property (as opposed to
inheriting it).
pub fn is_prototype_of(&self, value: &JsValue) -> bool
[src]
feature="ext"
only.The isPrototypeOf()
method checks if an object exists in another
object's prototype chain.
pub fn property_is_enumerable(&self, property: &JsValue) -> bool
[src]
feature="ext"
only.The propertyIsEnumerable()
method returns a Boolean indicating
whether the specified property is enumerable.
pub fn to_locale_string(&self) -> JsString
[src]
feature="ext"
only.The toLocaleString()
method returns a string representing the object.
This method is meant to be overridden by derived objects for
locale-specific purposes.
pub fn to_string(&self) -> JsString
[src]
feature="ext"
only.The toString()
method returns a string representing the object.
pub fn value_of(&self) -> Object
[src]
feature="ext"
only.The valueOf()
method returns the primitive value of the
specified object.
Trait Implementations
impl<T: JsCast> AsRef<JsValue> for ReadOnlyArray<T>
[src]
impl<T: JsCast> AsRef<Object> for ReadOnlyArray<T>
[src]
impl<T: JsCast> AsRef<ReadOnlyArray<T>> for ReadOnlyArray<T>
[src]
impl<T: JsCast> Clone for ReadOnlyArray<T>
[src]
fn clone(&self) -> Self
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T: JsCast> Debug for ReadOnlyArray<T>
[src]
impl<T: JsCast> Deref for ReadOnlyArray<T>
[src]
impl<T: Eq + JsCast> Eq for ReadOnlyArray<T>
[src]
impl<T: JsCast> From<Array> for ReadOnlyArray<T>
[src]
impl<T: JsCast> From<JsValue> for ReadOnlyArray<T>
[src]
impl<T: JsCast> From<ReadOnlyArray<T>> for JsValue
[src]
fn from(arr: ReadOnlyArray<T>) -> Self
[src]
impl<T: JsCast> From<ReadOnlyArray<T>> for Object
[src]
fn from(arr: ReadOnlyArray<T>) -> Self
[src]
impl<T: JsCast> FromWasmAbi for ReadOnlyArray<T>
[src]
type Abi = <Array as FromWasmAbi>::Abi
The wasm ABI type that this converts from when coming back out from the ABI boundary. Read more
unsafe fn from_abi(js: Self::Abi) -> Self
[src]
impl<'a, T: JsCast> IntoWasmAbi for &'a ReadOnlyArray<T>
[src]
type Abi = <&'a Array as IntoWasmAbi>::Abi
The wasm ABI type that this converts into when crossing the ABI boundary. Read more
fn into_abi(self) -> Self::Abi
[src]
impl<T: JsCast> JsCast for ReadOnlyArray<T>
[src]
fn instanceof(val: &JsValue) -> bool
[src]
fn unchecked_from_js(val: JsValue) -> Self
[src]
fn unchecked_from_js_ref(val: &JsValue) -> &Self
[src]
fn is_type_of(val: &JsValue) -> bool
[src]
fn has_type<T>(&self) -> bool where
T: JsCast,
[src]
T: JsCast,
fn dyn_into<T>(self) -> Result<T, Self> where
T: JsCast,
[src]
T: JsCast,
fn dyn_ref<T>(&self) -> Option<&T> where
T: JsCast,
[src]
T: JsCast,
fn unchecked_into<T>(self) -> T where
T: JsCast,
[src]
T: JsCast,
fn unchecked_ref<T>(&self) -> &T where
T: JsCast,
[src]
T: JsCast,
fn is_instance_of<T>(&self) -> bool where
T: JsCast,
[src]
T: JsCast,
impl<T: JsCast> OptionFromWasmAbi for ReadOnlyArray<T>
[src]
impl<'a, T: JsCast> OptionIntoWasmAbi for &'a ReadOnlyArray<T>
[src]
impl<T: PartialEq + JsCast> PartialEq<ReadOnlyArray<T>> for ReadOnlyArray<T>
[src]
fn eq(&self, other: &ReadOnlyArray<T>) -> bool
[src]
fn ne(&self, other: &ReadOnlyArray<T>) -> bool
[src]
impl<T: JsCast> RefFromWasmAbi for ReadOnlyArray<T>
[src]
type Abi = <Array as RefFromWasmAbi>::Abi
The wasm ABI type references to Self
are recovered from.
type Anchor = ManuallyDrop<Self>
The type that holds the reference to 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. Read more
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
[src]
impl<T: JsCast> StructuralEq for ReadOnlyArray<T>
[src]
impl<T: JsCast> StructuralPartialEq for ReadOnlyArray<T>
[src]
impl<T: JsCast> WasmDescribe for ReadOnlyArray<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for ReadOnlyArray<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> !Send for ReadOnlyArray<T>
impl<T> !Sync for ReadOnlyArray<T>
impl<T> Unpin for ReadOnlyArray<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ReadOnlyArray<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,