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: ITrait Implementations§
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<'js, T> AsProperty<'js, T> for Twhere
T: IntoJs<'js>,
impl<'js, T> AsProperty<'js, T> for Twhere
T: IntoJs<'js>,
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