From 6a88b351dcd66c565ed08f3c17033d06ff60bc15 Mon Sep 17 00:00:00 2001 From: Omer Yacine Date: Tue, 17 Sep 2024 10:01:27 +0300 Subject: [PATCH] suggestions by onur 1 doc comments & magic clippy rule :O --- clippy.toml | 4 ++++ mm2src/common/common.rs | 23 +++++++---------------- 2 files changed, 11 insertions(+), 16 deletions(-) create mode 100644 clippy.toml diff --git a/clippy.toml b/clippy.toml new file mode 100644 index 00000000000..eeac9f7826e --- /dev/null +++ b/clippy.toml @@ -0,0 +1,4 @@ +[[disallowed-methods]] +path = "futures::future::Future::wait" +replacement = "common::block_on_f01" +reason = "Use the default KDF async executor (using block_on/block_on_f01)." \ No newline at end of file diff --git a/mm2src/common/common.rs b/mm2src/common/common.rs index 58f74e76612..e390893baef 100644 --- a/mm2src/common/common.rs +++ b/mm2src/common/common.rs @@ -634,29 +634,20 @@ pub fn var(name: &str) -> Result { #[cfg(target_arch = "wasm32")] pub fn var(_name: &str) -> Result { ERR!("Environment variable not supported in WASM") } -#[cfg(not(target_arch = "wasm32"))] +/// Runs the given future on MM2's executor and waits for the result. +/// +/// This is compatible with futures 0.1. pub fn block_on_f01(f: F) -> Result where F: Future, { - if var("TRACE_BLOCK_ON").map(|v| v == "true") == Ok(true) { - let mut trace = String::with_capacity(4096); - stack_trace(&mut stack_trace_frame, &mut |l| trace.push_str(l)); - log::info!("block_on_f01 at\n{}", trace); - } - - wio::CORE.0.block_on(f.compat()) -} - -#[cfg(target_arch = "wasm32")] -pub fn block_on_f01(_f: F) -> Result -where - F: Future, -{ - panic!("block_on_f01 is not supported in WASM!"); + block_on(f.compat()) } #[cfg(not(target_arch = "wasm32"))] +/// Runs the given future on MM2's executor and waits for the result. +/// +/// This is compatible with futures 0.3. pub fn block_on(f: F) -> F::Output where F: Future03,