Skip to main content

Iterable

Trait Iterable 

Source
pub trait Iterable: Sized {
    type Item;

    // Required methods
    fn expand(self, scope: &Scope, body: &mut dyn FnMut(&Scope, Self::Item));
    fn expand_unroll(
        self,
        scope: &Scope,
        body: &mut dyn FnMut(&Scope, Self::Item),
    );

    // Provided method
    fn const_len(&self) -> Option<usize> { ... }
}
Expand description

Something that can be iterated on by a for loop. Currently only includes Range, StepBy and Sequence.

Required Associated Types§

Required Methods§

Source

fn expand(self, scope: &Scope, body: &mut dyn FnMut(&Scope, Self::Item))

Expand a runtime loop without unrolling

§Arguments
  • scope - the expansion scope
  • body - the loop body to be executed repeatedly

The body is a trait object rather than an impl FnMut so that this expands once per iterable instead of once per loop body. See for_expand.

Source

fn expand_unroll(self, scope: &Scope, body: &mut dyn FnMut(&Scope, Self::Item))

Expand an unrolled loop. The body should be invoced n times, where n is the number of iterations.

§Arguments
  • scope - the expansion scope
  • body - the loop body to be executed repeatedly

Provided Methods§

Source

fn const_len(&self) -> Option<usize>

Return the comptime length of this iterable, if possible

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§