[−][src]Macro genawaiter::unsafe_create_generator
Creates a generator on the stack. By-value, but not 100% safe.
⚠ This macro only exists for backwards compatibility. Prefer the safe generator_mut!
whenever possible.
This macro creates a generator with the name you pass in:
ⓘThis example is not tested
unsafe_create_generator!(my_name, ...) // Think of this as: let my_name = unsafe_create_generator!(...)
The full type of the new variable is Gen<'_, Y, R, impl Future>
. Y
is the type
yielded from the generator. R
is the type of the resume argument. Future::Output
is
the type returned upon completion of the generator.
Compared to generator_mut!
, this macro gives by-value access to the generator
(instead of a reference). In practice, this distinction does not matter at all, and you
pay for it by opening a small window for memory unsafety.
Safety
This macro has the same safety invariants as
Gen::new
.