[][src]Function safina::block_on

pub fn block_on<R>(fut: impl Send + Future<Output = R> + 'static) -> R

Executes the future on the current thread and returns its result. Panics if the future panics.

Panics if fut calls spawn to create a new task. Does not create an executor. Use Executor::block_on if you need fut to spawn new tasks.

Uses std::boxed::Box::pin to make the future Unpin. You can use block_on_unpin to avoid this allocation.

let result = safina_executor::block_on(async {
    prepare_request().await?;
    execute_request().await
})?;