[−][src]Macro genawaiter::stack::let_gen
Creates a generator.
The first argument is the name of the resulting variable.
ⓘThis example is not tested
let_gen!(my_generator, { /* ... */ }); // Think of this as the spiritual equivalent of: let mut my_generator = Gen::new(/* ... */);
The second argument is the body of the generator. It should contain one or
more calls to the yield_!
macro.
This macro is a shortcut for creating both a generator and its backing state
(called a Shelf
). If you (or your IDE) dislike
macros, you can also do the bookkeeping by hand by using
Gen::new
, though note that this requires you
to trade away safety.