From 013f00916437493b1bc560cc1990413243b075f7 Mon Sep 17 00:00:00 2001 From: Noah Date: Sun, 30 Oct 2022 19:53:38 -0700 Subject: [PATCH] Add borrowing rules test --- crates/yewdux/src/dispatch.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/crates/yewdux/src/dispatch.rs b/crates/yewdux/src/dispatch.rs index 52c8602..66e9bb9 100644 --- a/crates/yewdux/src/dispatch.rs +++ b/crates/yewdux/src/dispatch.rs @@ -535,6 +535,23 @@ mod tests { assert!(old != new); } + #[cfg(feature = "future")] + #[async_std::test] + async fn reduce_future_does_not_clash() { + use std::time::Duration; + + let dispatch = Dispatch::::new(); + + dispatch + .reduce_future(|state| async move { + async_std::task::sleep(Duration::from_millis(100)).await; + state + }) + .await; + + dispatch.reduce(|s| s); + } + #[test] fn reduce_mut_changes_value() { let old = get::();