Iterable

Struct Iterable 

Source
pub struct Iterable<I>(pub I);
Expand description

Converts a Rust iterator into a JavaScript iterable object.

The resulting object implements the JavaScript iterable protocol with a [Symbol.iterator] method that returns an iterator following the iterator protocol.

Note: The iterator can only be consumed once. Subsequent iterations will yield no values.

§Example

// Create an iterable from a Vec
let iter = Iterable::from(vec![1, 2, 3]);
ctx.globals().set("myIterable", iter)?;

// Use spread operator
let result: Vec<i32> = ctx.eval("[...myIterable]")?;
assert_eq!(result, vec![1, 2, 3]);

Tuple Fields§

§0: I

Trait Implementations§

Source§

impl<I> From<I> for Iterable<I>

Source§

fn from(iter: I) -> Self

Converts to this type from the input type.
Source§

impl<'js, I, T> IntoJs<'js> for Iterable<I>
where I: IntoIterator<Item = T> + 'js, I::IntoIter: 'js, T: IntoJs<'js> + 'js,

Source§

fn into_js(self, ctx: &Ctx<'js>) -> Result<Value<'js>>

Auto Trait Implementations§

§

impl<I> Freeze for Iterable<I>
where I: Freeze,

§

impl<I> RefUnwindSafe for Iterable<I>
where I: RefUnwindSafe,

§

impl<I> Send for Iterable<I>
where I: Send,

§

impl<I> Sync for Iterable<I>
where I: Sync,

§

impl<I> Unpin for Iterable<I>
where I: Unpin,

§

impl<I> UnwindSafe for Iterable<I>
where I: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<'js, T> AsProperty<'js, T> for T
where T: IntoJs<'js>,

Source§

fn config( self, ctx: &Ctx<'js>, ) -> Result<(i32, Value<'js>, Value<'js>, Value<'js>), Error>

Property configuration Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<!> for T

Source§

fn from(t: !) -> T

Converts to this type from the input type.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'js, T> IntoArg<'js> for T
where T: IntoJs<'js>,

Source§

fn num_args(&self) -> usize

The number of arguments this value produces.
Source§

fn into_arg(self, args: &mut Args<'js>) -> Result<(), Error>

Convert the value into an argument.
Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ParallelSend for T