unsafe extern "C" fn generator_wrapper<Input, Output, Stack, F>(
            f_ptr: usize,
            stack_ptr: *mut usize,
        ) where
            Stack: stack::Stack,
            F: FnOnce(&Yielder<Input, Output>, Input),
        {
            let f = std::ptr::read(f_ptr as *const F);
            let (data, stack_ptr) = arch::swap(0, stack_ptr);
            let input = std::ptr::read(data as *const Input);
            let yielder = Yielder::new(stack_ptr);

            // It is not safe to unwind across the context switch.
            // The unwind will continue in the original context.
            match catch_unwind(AssertUnwindSafe(|| {
                f(&yielder, input);
            })) {
                Ok(_) => yielder.suspend_(GeneratorOutput::Finished),
                Err(panic) => yielder.suspend_(GeneratorOutput::Panic(panic)),
            };
        }
// This function will be written to the new stack (by `arch::init`) as the initial
// entry point. During the `arch::swap_and_link_stacks` call it will be called with
// the correct closure passed as the first argument. This function will never return.
// Yielding back into it after `yielder.suspend_(GeneratorOutput::Finished)` was
// called would be undefined behavior.
This function will be written to the new stack (by `arch::init`) as the initial
entry point. During the `arch::swap_and_link_stacks` call it will be called with
the correct closure passed as the first argument. This function will never return.
Yielding back into it after `yielder.suspend_(GeneratorOutput::Finished)` was
called would be undefined behavior.
This function will be written to the new stack ( by ` arch :: init ` ) as the initial entry point . During the ` arch :: swap_and_link_stacks ` call it will be called with the correct closure passed as the first argument . This function will never return . Yielding back into it after ` yielder . suspend_ ( GeneratorOutput :: Finished ) ` was called would be undefined behavior .
unsafe extern "C" fn generator_wrapper<Input, Output, Stack, F>(
            f_ptr: usize,
            stack_ptr: *mut usize,
        ) where
            Stack: stack::Stack,
            F: FnOnce(&Yielder<Input, Output>, Input),
        {
            let f = std::ptr::read(f_ptr as *const F);
            let (data, stack_ptr) = arch::swap(0, stack_ptr);
            let input = std::ptr::read(data as *const Input);
            let yielder = Yielder::new(stack_ptr);
            // It is not safe to unwind across the context switch.
            // The unwind will continue in the original context.
            match catch_unwind(AssertUnwindSafe(|| {
                f(&yielder, input);
            })) {
                Ok(_) => yielder.suspend_(GeneratorOutput::Finished),
                Err(panic) => yielder.suspend_(GeneratorOutput::Panic(panic)),
            };
        }
unsafe extern " " fn generator_wrapper < Input , Output , Stack , F > ( f_ptr : usize , stack_ptr : * mut usize , ) where Stack : stack :: Stack , F : FnOnce ( & Yielder < Input , Output > , Input ) , { let f = std :: ptr :: read ( f_ptr as * const F ) ; let ( data , stack_ptr ) = arch :: swap ( 0 , stack_ptr ) ; let input = std :: ptr :: read ( data as * const Input ) ; let yielder = Yielder :: new ( stack_ptr ) ; // It is not safe to unwind across the context switch. // The unwind will continue in the original context. match catch_unwind ( AssertUnwindSafe ( | | { f ( & yielder , input ) ; } ) ) { Ok ( _ ) => yielder . suspend_ ( GeneratorOutput :: Finished ) , Err ( panic ) => yielder . suspend_ ( GeneratorOutput :: Panic ( panic ) ) , } ; }
This function will be written to the new stack (by `arch::init`) as the initial
entry point.
This function will be written to the new stack ( by ` arch :: init ` ) as the initial entry point .
f_ptr
usize
stack_ptr
*mut usize
f_ptr
usize
stack_ptr
*mut usize