stateful_expr

Attribute Macro stateful_expr 

Source
#[stateful_expr]
Expand description

Like [stateful], but allows specifying a custom expression when passing the state variable. A more general version of stateful_cloned.

§Example

#[stateful(State<S>, state.clone())]
fn dense(x: i32) -> i32 {
    let y = ::mat_mul(::param(), x);
    y
}

Expands to:

fn dense(state: State<S>, x: i32) -> i32 {
    with_state! { state.clone();
        let y = ::mat_mul(::param(), x);
        y
    }
}