diff --git a/crates/clash-verge-draft/src/lib.rs b/crates/clash-verge-draft/src/lib.rs index 472dd430f..c1cba8f59 100644 --- a/crates/clash-verge-draft/src/lib.rs +++ b/crates/clash-verge-draft/src/lib.rs @@ -71,13 +71,13 @@ impl Draft { pub async fn with_data_modify(&self, f: F) -> Result where T: Send + Sync + 'static, - F: FnOnce(Box) -> Fut + Send, - Fut: std::future::Future, R), anyhow::Error>> + Send, + F: FnOnce(T) -> Fut + Send, + Fut: std::future::Future> + Send, { let (local, original_arc) = { let guard = self.inner.read(); let arc = Arc::clone(&guard.0); - (Box::new((*arc).clone()), arc) + ((*arc).clone(), arc) }; let (new_local, res) = f(local).await?; let mut guard = self.inner.write(); diff --git a/crates/clash-verge-draft/tests/test_me.rs b/crates/clash-verge-draft/tests/test_me.rs index 3221f1af6..1d1c1bc66 100644 --- a/crates/clash-verge-draft/tests/test_me.rs +++ b/crates/clash-verge-draft/tests/test_me.rs @@ -195,7 +195,7 @@ mod tests { // 使用 with_data_modify 异步(立即就绪)地更新 committed let res = block_on_ready(draft.with_data_modify(|mut v| async move { v.enable_auto_launch = Some(true); - Ok((Box::new(*v), "done")) // Dereference v to get Box + Ok((v, "done")) })); assert_eq!( { @@ -217,7 +217,7 @@ mod tests { #[allow(clippy::unwrap_used)] let err = block_on_ready(draft.with_data_modify(|v| async move { drop(v); - Err::<(Box, ()), _>(anyhow!("boom")) + Err::<(IVerge, ()), _>(anyhow!("boom")) })) .unwrap_err(); @@ -243,7 +243,7 @@ mod tests { #[allow(clippy::unwrap_used)] block_on_ready(draft.with_data_modify(|mut v| async move { v.enable_auto_launch = Some(false); // 与草稿不同 - Ok((Box::new(*v), ())) // Dereference v to get Box + Ok((v, ())) })) .unwrap();