Skip to main content

Iter

Struct Iter 

Source
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: I

Trait Implementations§

Source§

impl<I> IntoValue for Iter<I>
where I: IntoIterator, I::Item: IntoValue,

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. 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<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<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.