Skip to main content

state

Function state 

Source
pub fn state<'t, S, L>(tick: &'t Tick<L>) -> StateBuilder<'t, S, L>
Available on stageleft_runtime only.
Expand description

Creates a stateful cycle with an initial value for use in sliced!.

The tick (which is the source of truth for lifetimes) is bound first, returning a StateBuilder which accepts the user-provided initializer via StateBuilder::build. This two-step layout ensures that type errors caused by a bad initializer are attributed to the initializer argument rather than the tick or the entire macro invocation.

The initial value is computed from a closure that receives the location for the body of the slice.

The initial value is used on the first iteration, and subsequent iterations receive the value assigned to the mutable binding at the end of the previous iteration.