pub fn block_on<F: 'static + Future<Output = ()>>(future: F) {
    let future_ptr = Box::into_raw(Box::new(future));
    let future_ptr_ptr: *mut *mut dyn Future<Output = ()> = Box::into_raw(Box::new(future_ptr));
    let mut pinned_future = unsafe { Pin::new_unchecked(&mut *future_ptr) };
    if pinned_future
        .as_mut()
        .poll(&mut Context::from_waker(&waker::waker(
            future_ptr_ptr as *const (),
        )))
        .is_ready()
    {
        unsafe {
            let _ = Box::from_raw(future_ptr);
            let _ = Box::from_raw(future_ptr_ptr);
        }
    }
}
/// Must be called on every top-level future corresponding to a method call of a
/// canister by the IC.
///
/// Saves the pointer to the future on the heap and kickstarts the future by
/// polling it once. During the polling we also need to provide the waker
/// callback which is triggered after the future made progress.
/// The waker would then poll the future one last time to advance it to
/// the final state. For that, we pass the future pointer to the waker, so that
/// it can be restored into a box from a raw pointer and then dropped if not
/// needed anymore.
///
/// Technically, we store 2 pointers on the heap: the pointer to the future
/// itself, and a pointer to that pointer. The reason for this is that the waker
/// API requires us to pass one thin pointer, while a a pointer to a `dyn Trait`
/// can only be fat. So we create one additional thin pointer, pointing to the
/// fat pointer and pass it instead.
Must be called on every top-level future corresponding to a method call of a
canister by the IC.

Saves the pointer to the future on the heap and kickstarts the future by
polling it once. During the polling we also need to provide the waker
callback which is triggered after the future made progress.
The waker would then poll the future one last time to advance it to
the final state. For that, we pass the future pointer to the waker, so that
it can be restored into a box from a raw pointer and then dropped if not
needed anymore.

Technically, we store 2 pointers on the heap: the pointer to the future
itself, and a pointer to that pointer. The reason for this is that the waker
API requires us to pass one thin pointer, while a a pointer to a `dyn Trait`
can only be fat. So we create one additional thin pointer, pointing to the
fat pointer and pass it instead.
Must be called on every top - level future corresponding to a method call of a canister by the IC . Saves the pointer to the future on the heap and kickstarts the future by polling it once . During the polling we also need to provide the waker callback which is triggered after the future made progress . The waker would then poll the future one last time to advance it to the final state . For that we pass the future pointer to the waker so that it can be restored into a box from a raw pointer and then dropped if not needed anymore . Technically we store 2 pointers on the heap : the pointer to the future itself and a pointer to that pointer . The reason for this is that the waker API requires us to pass one thin pointer while a a pointer to a ` dyn Trait ` can only be fat . So we create one additional thin pointer pointing to the fat pointer and pass it instead .
pub fn block_on<F: 'static + Future<Output = ()>>(future: F) {
    let future_ptr = Box::into_raw(Box::new(future));
    let future_ptr_ptr: *mut *mut dyn Future<Output = ()> = Box::into_raw(Box::new(future_ptr));
    let mut pinned_future = unsafe { Pin::new_unchecked(&mut *future_ptr) };
    if pinned_future
        .as_mut()
        .poll(&mut Context::from_waker(&waker::waker(
            future_ptr_ptr as *const (),
        )))
        .is_ready()
    {
        unsafe {
            let _ = Box::from_raw(future_ptr);
            let _ = Box::from_raw(future_ptr_ptr);
        }
    }
}
pub fn block_on < F : ' static + Future < Output = ( ) > > ( future : F ) { let future_ptr = Box :: into_raw ( Box :: new ( future ) ) ; let future_ptr_ptr : * mut * mut dyn Future < Output = ( ) > = Box :: into_raw ( Box :: new ( future_ptr ) ) ; let mut pinned_future = unsafe { Pin :: new_unchecked ( & mut * future_ptr ) } ; if pinned_future . as_mut ( ) . poll ( & mut Context :: from_waker ( & waker :: waker ( future_ptr_ptr as * const ( ) , ) ) ) . is_ready ( ) { unsafe { let _ = Box :: from_raw ( future_ptr ) ; let _ = Box :: from_raw ( future_ptr_ptr ) ; } } }
Must be called on every top-level future corresponding to a method call of a
canister by the IC.
Must be called on every top - level future corresponding to a method call of a canister by the IC .
future
F