[][src]Struct ducc::Array

pub struct Array<'ducc>(_);

Reference to a JavaScript array.

Implementations

impl<'ducc> Array<'ducc>[src]

pub fn into_object(self) -> Object<'ducc>[src]

Consumes the array and returns it as a JavaScript object. This is inexpensive, since an array is an object.

pub fn get<V: FromValue<'ducc>>(&self, index: u32) -> Result<V>[src]

Get the value using the given array index. Returns Value::Undefined if no element at the index exists.

Errors

This function returns an error if:

  • FromValue::from_value fails for the element

pub fn set<V: ToValue<'ducc>>(&self, index: u32, value: V) -> Result<()>[src]

Sets an array element using the given index and value.

Errors

This function returns an error if:

  • ToValue::to_value fails for the value

pub fn len(&self) -> Result<usize>[src]

Returns the number of elements in the array using the calculation Math.floor(ToNumber(array.length)). This function can return an error if the ToNumber implementation fails or if the length getter fails.

pub fn push<V: ToValue<'ducc>>(&self, value: V) -> Result<()>[src]

Pushes an element to the end of the array. This is a shortcut for set using len as the index.

pub fn elements<V: FromValue<'ducc>>(self) -> Elements<'ducc, V>[src]

Returns an iterator over the array's indexable values.

Trait Implementations

impl<'ducc> Clone for Array<'ducc>[src]

impl<'ducc> Debug for Array<'ducc>[src]

impl<'ducc> FromValue<'ducc> for Array<'ducc>[src]

impl<'ducc> ToValue<'ducc> for Array<'ducc>[src]

Auto Trait Implementations

impl<'ducc> RefUnwindSafe for Array<'ducc>

impl<'ducc> !Send for Array<'ducc>

impl<'ducc> !Sync for Array<'ducc>

impl<'ducc> Unpin for Array<'ducc>

impl<'ducc> UnwindSafe for Array<'ducc>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.