pub struct Array<T>(pub T);Expand description
Extracts a JavaScript array into a Rust collection or converts a collection to a JS array.
Any collection that implements FromIterator and IntoIterator can be extracted. Extraction
fails with ArrayError if the value is not an array or an element fails to be extracted.
§Example
#[neon::export]
fn list_of_strings(Array(arr): Array<Vec<String>>) -> Array<Vec<String>> {
Array(arr)
}
#[neon::export]
fn double(Array(arr): Array<Vec<f64>>) -> Array<impl Iterator<Item = f64>> {
Array(arr.into_iter().map(|x| x * 2.0))
}
#[neon::export]
fn dedupe(set: Array<HashSet<String>>) -> Array<HashSet<String>> {
set
}Note: Only native JS arrays are accepted. For typed arrays use Uint8Array,
Float64Array, etc.
Tuple Fields§
§0: TTrait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Array<T>where
T: Freeze,
impl<T> RefUnwindSafe for Array<T>where
T: RefUnwindSafe,
impl<T> Send for Array<T>where
T: Send,
impl<T> Sync for Array<T>where
T: Sync,
impl<T> Unpin for Array<T>where
T: Unpin,
impl<T> UnwindSafe for Array<T>where
T: UnwindSafe,
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
Mutably borrows from an owned value. Read more
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more