From 5c0abab1b7bf0f2858c451d6f0efc7ca0e138fc6 Mon Sep 17 00:00:00 2001 From: hozan23 Date: Sat, 29 Jun 2024 21:16:46 +0200 Subject: use shadown variables to name clones and place them between {} when spawning new tasks --- core/src/async_runtime/executor.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'core/src/async_runtime/executor.rs') diff --git a/core/src/async_runtime/executor.rs b/core/src/async_runtime/executor.rs index 88f6370..e0b707b 100644 --- a/core/src/async_runtime/executor.rs +++ b/core/src/async_runtime/executor.rs @@ -59,11 +59,13 @@ pub fn global_executor() -> Executor { #[cfg(feature = "tokio")] fn init_executor() -> Executor { let ex = Arc::new(tokio::runtime::Runtime::new().expect("cannot build tokio runtime")); - let ex_cloned = ex.clone(); thread::Builder::new() .name("tokio-executor".to_string()) - .spawn(move || { - catch_unwind(|| ex_cloned.block_on(std::future::pending::<()>())).ok(); + .spawn({ + let ex = ex.clone(); + move || { + catch_unwind(|| ex.block_on(std::future::pending::<()>())).ok(); + } }) .expect("cannot spawn tokio runtime thread"); Executor { inner: ex } -- cgit v1.2.3