grabbag_macros::sequence! [] [src]

macro_rules! sequence {
    ( $ind:ident: $sty:ty = $closed_form:expr ) => { ... };
    ( $seq:ident [ $ind:ident ]: $sty:ty = $($inits:expr),+ ... $closed_form:expr ) => { ... };
}

Expands to an expression implementing the Iterator trait, which yields successive elements of the given closed-form sequence.

For example, you can define the sequence of positive odd integers like so:

sequence![ n: u64 = 2*(n as u64) + 1 ]

You can also specify one or more initial members of the sequence that are also used in the closed form expression like so:

sequence![ a[n]: u64 = 1, 2... a[0]*(n as u64) + a[1] ]