From 8e012adb9422a516262284bbfec31b79a3cc6b82 Mon Sep 17 00:00:00 2001 From: Markus Kohlhase Date: Sun, 22 Dec 2024 18:22:55 +0100 Subject: [PATCH] Pass imutable reference of state to init function --- xilem_web/src/concurrent/memoized_await.rs | 24 +++++++++++----------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xilem_web/src/concurrent/memoized_await.rs b/xilem_web/src/concurrent/memoized_await.rs index dbb540fdc..28d176063 100644 --- a/xilem_web/src/concurrent/memoized_await.rs +++ b/xilem_web/src/concurrent/memoized_await.rs @@ -38,7 +38,7 @@ impl where FOut: fmt::Debug + 'static, F: Future + 'static, - InitFuture: Fn(&mut State, &Data) -> F, + InitFuture: Fn(State, &Data) -> F, { /// Debounce the `init_future` function, when `data` updates, /// when `reset_debounce_on_update == false` then this throttles updates each `milliseconds` @@ -64,7 +64,7 @@ impl where StreamItem: fmt::Debug + 'static, F: Stream + 'static, - InitStream: Fn(&mut State, &Data) -> F, + InitStream: Fn(State, &Data) -> F, { /// Debounce the `init_stream` function, when `data` updates, /// when `reset_debounce_on_update == false` then this throttles updates each `milliseconds` @@ -88,9 +88,9 @@ where fn init_future( m: &MemoizedFuture, thunk: Rc, - state: &mut State, + state: &State, ) where - InitFuture: Fn(&mut State, &Data) -> F + 'static, + InitFuture: Fn(&State, &Data) -> F + 'static, FOut: fmt::Debug + 'static, F: Future + 'static, { @@ -103,9 +103,9 @@ fn init_future( fn init_stream( m: &MemoizedFuture, thunk: Rc, - state: &mut State, + state: &State, ) where - InitStream: Fn(&mut State, &Data) -> F + 'static, + InitStream: Fn(&State, &Data) -> F + 'static, StreamItem: fmt::Debug + 'static, F: Stream + 'static, { @@ -148,7 +148,7 @@ where Data: PartialEq + 'static, FOut: fmt::Debug + 'static, F: Future + 'static, - InitFuture: Fn(&mut State, &Data) -> F + 'static, + InitFuture: Fn(&State, &Data) -> F + 'static, OA: OptionalAction + 'static, Callback: Fn(&mut State, FOut) -> OA + 'static, { @@ -206,7 +206,7 @@ where Data: PartialEq + 'static, StreamItem: fmt::Debug + 'static, F: Stream + 'static, - InitStream: Fn(&mut State, &Data) -> F + 'static, + InitStream: Fn(&State, &Data) -> F + 'static, OA: OptionalAction + 'static, Callback: Fn(&mut State, StreamItem) -> OA + 'static, { @@ -312,7 +312,7 @@ where State: 'static, Action: 'static, OA: OptionalAction + 'static, - InitFuture: Fn(&mut State, &Data) -> F + 'static, + InitFuture: Fn(&State, &Data) -> F + 'static, FOut: fmt::Debug + 'static, Data: PartialEq + 'static, F: Future + 'static, @@ -359,7 +359,7 @@ where State: 'static, Action: 'static, OA: OptionalAction + 'static, - InitStream: Fn(&mut State, &Data) -> F + 'static, + InitStream: Fn(&State, &Data) -> F + 'static, StreamItem: fmt::Debug + 'static, Data: PartialEq + 'static, F: Stream + 'static, @@ -405,7 +405,7 @@ where State: 'static, Action: 'static, OA: OptionalAction + 'static, - InitFuture: Fn(&mut State, &Data) -> F + 'static, + InitFuture: Fn(&State, &Data) -> F + 'static, FOut: fmt::Debug + 'static, Data: PartialEq + 'static, F: 'static, @@ -472,7 +472,7 @@ where init_future: I, ) -> MessageResult where - I: Fn(&Self, Rc, &mut State), + I: Fn(&Self, Rc, &State), { assert_eq!(id_path.len(), 1); if id_path[0].routing_id() == view_state.generation {