pub fn with_runtime<R>(run: impl FnOnce() -> R) -> R {
    if Handle::try_current().is_ok() {
        run()
    } else {
        let rt = RUNTIME.get_or_init(|| Runtime::new().expect("creating tokio runtime failed"));
        let handle = rt.handle();
        let guard = handle.enter();
        let r = run();
        drop(guard);
        r
    }
}
/// Runs a closure inside of a runtime.
///
/// If we already are inside of a runtime, that runtime
/// is used.
///
/// If we are not in a runtime a new runtime is created.
///
/// For now there is no way to interact with that runtime besides
/// this method, similar there is for now no way to set an externally
/// created runtime.
///
/// # Panics
///
/// Panics if a runtime needs to be created and that fails.
///
/// Normally creating a runtime doesn't fail.
///
/// Though `tokio` doesn't document when runtime creation
/// can fail.
Runs a closure inside of a runtime.
If we already are inside of a runtime, that runtime
is used.

If we are not in a runtime a new runtime is created.

For now there is no way to interact with that runtime besides
this method, similar there is for now no way to set an externally
created runtime.
Runs a closure inside of a runtime . If we already are inside of a runtime that runtime is used . If we are not in a runtime a new runtime is created . For now there is no way to interact with that runtime besides this method similar there is for now no way to set an externally created runtime .
pub fn with_runtime<R>(run: impl FnOnce() -> R) -> R {
    if Handle::try_current().is_ok() {
        run()
    } else {
        let rt = RUNTIME.get_or_init(|| Runtime::new().expect("creating tokio runtime failed"));
        let handle = rt.handle();
        let guard = handle.enter();
        let r = run();
        drop(guard);
        r
    }
}
pub fn with_runtime < R > ( run : impl FnOnce ( ) -> R ) -> R { if Handle :: try_current ( ) . is_ok ( ) { run ( ) } else { let rt = RUNTIME . get_or_init ( | | Runtime :: new ( ) . expect ( " " ) ) ; let handle = rt . handle ( ) ; let guard = handle . enter ( ) ; let r = run ( ) ; drop ( guard ) ; r } }
Runs a closure inside of a runtime.
Runs a closure inside of a runtime .
run
impl FnOnce() -> R
panics
Panics if a runtime needs to be created and that fails.

Normally creating a runtime doesn't fail.

Though `tokio` doesn't document when runtime creation
can fail.
Panics if a runtime needs to be created and that fails . Normally creating a runtime doesn ' t fail . Though ` tokio ` doesn ' t document when runtime creation can fail .