Hi all,

I am trying to write a generator function that returns a struct containing some value and an owned closure computing the next value.

fn generate_something() -> gen_res<T> { ...blah... }

struct gen_res<T> {
    val : T,
    next : ~fn() -> gen_res<T>,
}

For every closure I create I need to append some computation data in a Cons like fashion (I don't mutate old data). Is that possible without cloning data?

(In my specific case I want to write a prime number generator that computes one prime at a time and keeps track of discovered prime numbers. I know there are other C-like ways to do it but I want to play around with closures).
_______________________________________________
Rust-dev mailing list
[email protected]
https://mail.mozilla.org/listinfo/rust-dev

Reply via email to