Function sample::signal::gen_mut [] [src]

pub fn gen_mut<G, F>(gen_mut: G) -> GenMut<G, F> where G: FnMut() -> F, F: Frame

A signal that generates frames using the given function which may mutate some state.

Example

extern crate sample;

fn main() {
    let mut f = [0.0];
    let mut frames = sample::signal::gen_mut(|| {
        let r = f;
        f[0] += 0.1;
        r
    });
    assert_eq!(frames.next(), Some([0.0]));
    assert_eq!(frames.next(), Some([0.1]));
    assert_eq!(frames.next(), Some([0.2]));
}