pub fn block_on<R>(fut: impl Future<Output = R> + 'static) -> R
Expand description
Executes the future on the current thread and returns its result.
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.
Panics
Panics if the future panics.
Panics if fut
calls spawn
to create a new task.
Example
let result = safina_executor::block_on(async {
prepare_request().await?;
execute_request().await
})?;