pub struct Iter<I>(pub I);Expand description
Wraps an iterable so it becomes a loop source (a Somni iterator value).
ⓘ
env.value("items", Iter(vec![1u64, 2, 3]));
// #for x: int in items ...Elements must themselves be scalar IntoValues; iterators of iterators are not
supported (the element type set has no iterator type).
Single-pass: a value registered with Iter is backed by a one-shot iterator, so it
can only be consumed by a single for loop. To iterate the same source repeatedly (e.g.
an inner loop nested inside an outer loop), register a host function that returns a
fresh iterator each call and invoke it in the loop header (#for x: int in items()).
Tuple Fields§
§0: ITrait Implementations§
Source§impl<I> IntoValue for Iter<I>
impl<I> IntoValue for Iter<I>
Source§fn into_value(self) -> TypedValue<TemplateTypes>
fn into_value(self) -> TypedValue<TemplateTypes>
Converts
self into a Somni value.Auto Trait Implementations§
impl<I> Freeze for Iter<I>where
I: Freeze,
impl<I> RefUnwindSafe for Iter<I>where
I: RefUnwindSafe,
impl<I> Send for Iter<I>where
I: Send,
impl<I> Sync for Iter<I>where
I: Sync,
impl<I> Unpin for Iter<I>where
I: Unpin,
impl<I> UnsafeUnpin for Iter<I>where
I: UnsafeUnpin,
impl<I> UnwindSafe for Iter<I>where
I: 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