diff --git a/leptos/src/into_view.rs b/leptos/src/into_view.rs index 653669b59..fff6d2c70 100644 --- a/leptos/src/into_view.rs +++ b/leptos/src/into_view.rs @@ -53,7 +53,7 @@ impl RenderHtml for View { self.0.resolve().await } - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.0.dry_resolve(); } diff --git a/leptos_server/src/lib.rs b/leptos_server/src/lib.rs index 897b23135..eb6c4a64a 100644 --- a/leptos_server/src/lib.rs +++ b/leptos_server/src/lib.rs @@ -169,7 +169,7 @@ mod view_implementations { R: Renderer, { type Output> = Box< - dyn Fn() -> Suspend< + dyn FnMut() -> Suspend< Pin< Box< dyn Future< @@ -203,7 +203,7 @@ mod view_implementations { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.read(); } diff --git a/meta/src/body.rs b/meta/src/body.rs index 1f0cdc113..1592b8165 100644 --- a/meta/src/body.rs +++ b/meta/src/body.rs @@ -126,7 +126,7 @@ impl RenderHtml for BodyView { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/meta/src/html.rs b/meta/src/html.rs index 4364d8567..e145248d1 100644 --- a/meta/src/html.rs +++ b/meta/src/html.rs @@ -139,7 +139,7 @@ impl RenderHtml for HtmlView { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/meta/src/lib.rs b/meta/src/lib.rs index f8968961e..7d34952ac 100644 --- a/meta/src/lib.rs +++ b/meta/src/lib.rs @@ -383,7 +383,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.el.dry_resolve() } @@ -488,7 +488,7 @@ impl RenderHtml for MetaTagsView { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/meta/src/title.rs b/meta/src/title.rs index 7f43c7d18..dc25ba94d 100644 --- a/meta/src/title.rs +++ b/meta/src/title.rs @@ -239,7 +239,7 @@ impl RenderHtml for TitleView { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/router/src/flat_router.rs b/router/src/flat_router.rs index 4cbdc7a5c..aafa86d60 100644 --- a/router/src/flat_router.rs +++ b/router/src/flat_router.rs @@ -476,7 +476,7 @@ where >::View, > as RenderHtml>::MIN_LENGTH; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/router/src/nested_router.rs b/router/src/nested_router.rs index d7c12e06a..02fa61462 100644 --- a/router/src/nested_router.rs +++ b/router/src/nested_router.rs @@ -230,7 +230,7 @@ where const MIN_LENGTH: usize = 0; // TODO - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/tachys/src/html/element/mod.rs b/tachys/src/html/element/mod.rs index 1bbc07d4b..6ea614eec 100644 --- a/tachys/src/html/element/mod.rs +++ b/tachys/src/html/element/mod.rs @@ -224,7 +224,7 @@ where + E::TAG.len() }; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.children.dry_resolve() } diff --git a/tachys/src/html/islands.rs b/tachys/src/html/islands.rs index b05d36794..05295e3ad 100644 --- a/tachys/src/html/islands.rs +++ b/tachys/src/html/islands.rs @@ -100,7 +100,7 @@ where + "data-component".len() + View::MIN_LENGTH; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.view.dry_resolve() } @@ -219,7 +219,7 @@ where + "".len() + View::MIN_LENGTH; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.view.dry_resolve() } diff --git a/tachys/src/html/mod.rs b/tachys/src/html/mod.rs index ff8756a8d..3362b2b31 100644 --- a/tachys/src/html/mod.rs +++ b/tachys/src/html/mod.rs @@ -44,7 +44,7 @@ where const MIN_LENGTH: usize = "".len(); - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/tachys/src/oco.rs b/tachys/src/oco.rs index cc36a543d..93392b927 100644 --- a/tachys/src/oco.rs +++ b/tachys/src/oco.rs @@ -40,7 +40,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/tachys/src/reactive_graph/class.rs b/tachys/src/reactive_graph/class.rs index 67f245283..05abe89c0 100644 --- a/tachys/src/reactive_graph/class.rs +++ b/tachys/src/reactive_graph/class.rs @@ -22,12 +22,15 @@ where 0 } - fn to_html(self, class: &mut String) { + fn to_html(mut self, class: &mut String) { let value = self.invoke(); value.to_html(class); } - fn hydrate(self, el: &R::Element) -> Self::State { + fn hydrate( + mut self, + el: &R::Element, + ) -> Self::State { // TODO FROM_SERVER vs template let el = el.clone(); RenderEffect::new(move |prev| { @@ -42,7 +45,7 @@ where .into() } - fn build(self, el: &R::Element) -> Self::State { + fn build(mut self, el: &R::Element) -> Self::State { let el = el.to_owned(); RenderEffect::new(move |prev| { let value = self.invoke(); @@ -56,7 +59,7 @@ where .into() } - fn rebuild(self, state: &mut Self::State) { + fn rebuild(mut self, state: &mut Self::State) { let prev_effect = std::mem::take(&mut state.0); let prev_value = prev_effect.as_ref().and_then(|e| e.take_value()); drop(prev_effect); @@ -99,7 +102,7 @@ where } fn to_html(self, class: &mut String) { - let (name, f) = self; + let (name, mut f) = self; let include = *f.invoke().borrow(); if include { <&str as IntoClass>::to_html(name, class); @@ -108,7 +111,7 @@ where fn hydrate(self, el: &R::Element) -> Self::State { // TODO FROM_SERVER vs template - let (name, f) = self; + let (name, mut f) = self; let class_list = R::class_list(el); let name = R::intern(name); @@ -129,7 +132,7 @@ where } fn build(self, el: &R::Element) -> Self::State { - let (name, f) = self; + let (name, mut f) = self; let class_list = R::class_list(el); let name = R::intern(name); @@ -184,7 +187,7 @@ where } fn to_html(self, class: &mut String) { - let (names, f) = self; + let (names, mut f) = self; let include = *f.invoke().borrow(); if include { for name in names { @@ -195,7 +198,7 @@ where fn hydrate(self, el: &R::Element) -> Self::State { // TODO FROM_SERVER vs template - let (names, f) = self; + let (names, mut f) = self; let class_list = R::class_list(el); RenderEffect::new(move |prev: Option<(R::ClassList, bool)>| { @@ -220,7 +223,7 @@ where } fn build(self, el: &R::Element) -> Self::State { - let (names, f) = self; + let (names, mut f) = self; let class_list = R::class_list(el); RenderEffect::new(move |prev: Option<(R::ClassList, bool)>| { diff --git a/tachys/src/reactive_graph/inner_html.rs b/tachys/src/reactive_graph/inner_html.rs index dd0ac6575..6a604a3ac 100644 --- a/tachys/src/reactive_graph/inner_html.rs +++ b/tachys/src/reactive_graph/inner_html.rs @@ -20,7 +20,7 @@ where 0 } - fn to_html(self, buf: &mut String) { + fn to_html(mut self, buf: &mut String) { let value = self.invoke(); value.to_html(buf); } @@ -28,7 +28,7 @@ where fn to_template(_buf: &mut String) {} fn hydrate( - self, + mut self, el: &::Element, ) -> Self::State { let el = el.to_owned(); @@ -43,7 +43,7 @@ where }) } - fn build(self, el: &::Element) -> Self::State { + fn build(mut self, el: &::Element) -> Self::State { let el = el.to_owned(); RenderEffect::new(move |prev| { let value = self.invoke(); diff --git a/tachys/src/reactive_graph/mod.rs b/tachys/src/reactive_graph/mod.rs index 29b6c1afb..2cfe12a1c 100644 --- a/tachys/src/reactive_graph/mod.rs +++ b/tachys/src/reactive_graph/mod.rs @@ -51,7 +51,7 @@ where type State = RenderEffectState; #[track_caller] - fn build(self) -> Self::State { + fn build(mut self) -> Self::State { RenderEffect::new(move |prev| { let value = self.invoke(); if let Some(mut state) = prev { @@ -157,11 +157,11 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.invoke().dry_resolve(); } - async fn resolve(self) -> Self::AsyncOutput { + async fn resolve(mut self) -> Self::AsyncOutput { self.invoke().resolve().await } @@ -169,13 +169,13 @@ where V::MIN_LENGTH } - fn to_html_with_buf(self, buf: &mut String, position: &mut Position) { + fn to_html_with_buf(mut self, buf: &mut String, position: &mut Position) { let value = self.invoke(); value.to_html_with_buf(buf, position) } fn to_html_async_with_buf( - self, + mut self, buf: &mut StreamBuilder, position: &mut Position, ) where @@ -186,7 +186,7 @@ where } fn hydrate( - self, + mut self, cursor: &Cursor, position: &PositionState, ) -> Self::State { @@ -212,10 +212,10 @@ where R: Renderer + 'static, { type Output> = - Box V::Output + Send>; + Box V::Output + Send>; fn add_any_attr>( - self, + mut self, attr: NewAttr, ) -> Self::Output where @@ -305,7 +305,7 @@ where 0 } - fn to_html(self, key: &str, buf: &mut String) { + fn to_html(mut self, key: &str, buf: &mut String) { let value = self.invoke(); value.to_html(key, buf); } @@ -313,7 +313,7 @@ where fn to_template(_key: &str, _buf: &mut String) {} fn hydrate( - self, + mut self, key: &str, el: &::Element, ) -> Self::State { @@ -333,7 +333,11 @@ where .into() } - fn build(self, el: &::Element, key: &str) -> Self::State { + fn build( + mut self, + el: &::Element, + key: &str, + ) -> Self::State { let key = R::intern(key); let key = key.to_owned(); let el = el.to_owned(); @@ -363,40 +367,40 @@ where } } -pub type SharedReactiveFunction = Arc T + Send>>; +pub type SharedReactiveFunction = Arc T + Send>>; pub trait ReactiveFunction: Send + 'static { type Output; - fn invoke(&self) -> Self::Output; + fn invoke(&mut self) -> Self::Output; - fn into_shared(self) -> Arc Self::Output + Send>>; + fn into_shared(self) -> Arc Self::Output + Send>>; } -impl ReactiveFunction for Arc T + Send>> { +impl ReactiveFunction for Arc T + Send>> { type Output = T; - fn invoke(&self) -> Self::Output { - let fun = self.lock().expect("lock poisoned"); + fn invoke(&mut self) -> Self::Output { + let mut fun = self.lock().expect("lock poisoned"); fun() } - fn into_shared(self) -> Arc Self::Output + Send>> { + fn into_shared(self) -> Arc Self::Output + Send>> { self } } impl ReactiveFunction for F where - F: Fn() -> T + Send + 'static, + F: FnMut() -> T + Send + 'static, { type Output = T; - fn invoke(&self) -> Self::Output { + fn invoke(&mut self) -> Self::Output { self() } - fn into_shared(self) -> Arc Self::Output + Send>> { + fn into_shared(self) -> Arc Self::Output + Send>> { Arc::new(Mutex::new(self)) } } @@ -472,7 +476,7 @@ mod stable { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self @@ -616,7 +620,7 @@ mod stable { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/tachys/src/reactive_graph/owned.rs b/tachys/src/reactive_graph/owned.rs index cf642776f..17bb49b90 100644 --- a/tachys/src/reactive_graph/owned.rs +++ b/tachys/src/reactive_graph/owned.rs @@ -157,7 +157,7 @@ where OwnedView { owner, view, rndr } } - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.owner.with(|| self.view.dry_resolve()); } } diff --git a/tachys/src/reactive_graph/property.rs b/tachys/src/reactive_graph/property.rs index c053929c2..bca87398c 100644 --- a/tachys/src/reactive_graph/property.rs +++ b/tachys/src/reactive_graph/property.rs @@ -18,7 +18,7 @@ where type CloneableOwned = SharedReactiveFunction; fn hydrate( - self, + mut self, el: &::Element, key: &str, ) -> Self::State { @@ -37,7 +37,11 @@ where }) } - fn build(self, el: &::Element, key: &str) -> Self::State { + fn build( + mut self, + el: &::Element, + key: &str, + ) -> Self::State { let key = R::intern(key); let key = key.to_owned(); let el = el.to_owned(); diff --git a/tachys/src/reactive_graph/style.rs b/tachys/src/reactive_graph/style.rs index 841a39a57..78db663cf 100644 --- a/tachys/src/reactive_graph/style.rs +++ b/tachys/src/reactive_graph/style.rs @@ -14,7 +14,7 @@ where type CloneableOwned = (&'static str, SharedReactiveFunction); fn to_html(self, style: &mut String) { - let (name, f) = self; + let (name, mut f) = self; let value = f.invoke(); style.push_str(name); style.push(':'); @@ -23,7 +23,7 @@ where } fn hydrate(self, el: &R::Element) -> Self::State { - let (name, f) = self; + let (name, mut f) = self; let name = R::intern(name); // TODO FROM_SERVER vs template let style = R::style(el); @@ -51,7 +51,7 @@ where } fn build(self, el: &R::Element) -> Self::State { - let (name, f) = self; + let (name, mut f) = self; let name = R::intern(name); let style = R::style(el); RenderEffect::new(move |prev| { @@ -98,12 +98,15 @@ where type Cloneable = SharedReactiveFunction; type CloneableOwned = SharedReactiveFunction; - fn to_html(self, style: &mut String) { + fn to_html(mut self, style: &mut String) { let value = self.invoke(); value.to_html(style); } - fn hydrate(self, el: &R::Element) -> Self::State { + fn hydrate( + mut self, + el: &R::Element, + ) -> Self::State { // TODO FROM_SERVER vs template let el = el.clone(); RenderEffect::new(move |prev| { @@ -117,7 +120,7 @@ where }) } - fn build(self, el: &R::Element) -> Self::State { + fn build(mut self, el: &R::Element) -> Self::State { let el = el.clone(); RenderEffect::new(move |prev| { let value = self.invoke(); diff --git a/tachys/src/reactive_graph/suspense.rs b/tachys/src/reactive_graph/suspense.rs index d8df1ec91..b1685ea19 100644 --- a/tachys/src/reactive_graph/suspense.rs +++ b/tachys/src/reactive_graph/suspense.rs @@ -225,5 +225,5 @@ where Some(self.0.await) } - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} } diff --git a/tachys/src/view/any_view.rs b/tachys/src/view/any_view.rs index a69ea8a73..b0a556a79 100644 --- a/tachys/src/view/any_view.rs +++ b/tachys/src/view/any_view.rs @@ -40,7 +40,7 @@ where resolve: fn(Box) -> Pin> + Send>>, #[cfg(feature = "ssr")] - dry_resolve: fn(&Box), + dry_resolve: fn(&mut Box), #[cfg(feature = "hydrate")] #[cfg(feature = "hydrate")] #[allow(clippy::type_complexity)] @@ -144,10 +144,10 @@ where let value = Box::new(self) as Box; #[cfg(feature = "ssr")] - let dry_resolve = |value: &Box| { + let dry_resolve = |value: &mut Box| { let value = value - .downcast_ref::() - .expect("AnyView::dry_resolve could not be downcast"); + .downcast_mut::() + .expect("AnyView::resolve could not be downcast"); value.dry_resolve(); }; @@ -304,10 +304,10 @@ where { type AsyncOutput = Self; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { #[cfg(feature = "ssr")] { - (self.dry_resolve)(&self.value) + (self.dry_resolve)(&mut self.value) } #[cfg(not(feature = "ssr"))] panic!( diff --git a/tachys/src/view/either.rs b/tachys/src/view/either.rs index 53a2f3767..4ca9e1145 100644 --- a/tachys/src/view/either.rs +++ b/tachys/src/view/either.rs @@ -149,7 +149,7 @@ where { type AsyncOutput = Either; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { match self { Either::Left(left) => left.dry_resolve(), Either::Right(right) => right.dry_resolve(), @@ -337,7 +337,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { todo!() } @@ -551,7 +551,7 @@ macro_rules! tuples { const MIN_LENGTH: usize = max_usize(&[$($ty ::MIN_LENGTH,)*]); - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { match self { $([]::$ty(this) => { this.dry_resolve(); diff --git a/tachys/src/view/error_boundary.rs b/tachys/src/view/error_boundary.rs index c4975b0cc..b39449b53 100644 --- a/tachys/src/view/error_boundary.rs +++ b/tachys/src/view/error_boundary.rs @@ -143,8 +143,8 @@ where const MIN_LENGTH: usize = T::MIN_LENGTH; - fn dry_resolve(&self) { - if let Ok(inner) = self.as_ref() { + fn dry_resolve(&mut self) { + if let Ok(inner) = self.as_mut() { inner.dry_resolve() } } diff --git a/tachys/src/view/iterators.rs b/tachys/src/view/iterators.rs index 3bd5a77bf..a5e499c5d 100644 --- a/tachys/src/view/iterators.rs +++ b/tachys/src/view/iterators.rs @@ -73,8 +73,8 @@ where const MIN_LENGTH: usize = T::MIN_LENGTH; - fn dry_resolve(&self) { - if let Some(inner) = self.as_ref() { + fn dry_resolve(&mut self) { + if let Some(inner) = self.as_mut() { inner.dry_resolve(); } } @@ -313,8 +313,8 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) { - for inner in self { + fn dry_resolve(&mut self) { + for inner in self.iter_mut() { inner.dry_resolve(); } } diff --git a/tachys/src/view/keyed.rs b/tachys/src/view/keyed.rs index f24f035f4..3d8cd14b1 100644 --- a/tachys/src/view/keyed.rs +++ b/tachys/src/view/keyed.rs @@ -199,7 +199,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { // TODO... } diff --git a/tachys/src/view/mod.rs b/tachys/src/view/mod.rs index f4499404b..940f7eabf 100644 --- a/tachys/src/view/mod.rs +++ b/tachys/src/view/mod.rs @@ -67,7 +67,7 @@ where const MIN_LENGTH: usize; - fn dry_resolve(&self); + fn dry_resolve(&mut self); /// Waits for any asynchronous sections of the view to load and returns the output. fn resolve(self) -> impl Future + Send; diff --git a/tachys/src/view/primitives.rs b/tachys/src/view/primitives.rs index f4cf13af6..8f595e19c 100644 --- a/tachys/src/view/primitives.rs +++ b/tachys/src/view/primitives.rs @@ -73,7 +73,7 @@ macro_rules! render_primitive { const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/tachys/src/view/static_types.rs b/tachys/src/view/static_types.rs index 4fc93b66f..0e15252a3 100644 --- a/tachys/src/view/static_types.rs +++ b/tachys/src/view/static_types.rs @@ -166,7 +166,7 @@ where const MIN_LENGTH: usize = V.len(); - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} // this won't actually compile because if a weird interaction because the const &'static str and // the RPITIT, so we just refine it to a concrete future type; this will never change in any diff --git a/tachys/src/view/strings.rs b/tachys/src/view/strings.rs index ad3916c46..a2c492d98 100644 --- a/tachys/src/view/strings.rs +++ b/tachys/src/view/strings.rs @@ -43,7 +43,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self @@ -168,7 +168,7 @@ where const MIN_LENGTH: usize = 0; type AsyncOutput = Self; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self @@ -358,7 +358,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self @@ -453,7 +453,7 @@ where const MIN_LENGTH: usize = 0; - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} async fn resolve(self) -> Self::AsyncOutput { self diff --git a/tachys/src/view/template.rs b/tachys/src/view/template.rs index 39caa1ebf..94ab9628d 100644 --- a/tachys/src/view/template.rs +++ b/tachys/src/view/template.rs @@ -92,7 +92,7 @@ where self.view.hydrate::(cursor, position) } - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { todo!() } diff --git a/tachys/src/view/tuples.rs b/tachys/src/view/tuples.rs index 776514947..2aa128c21 100644 --- a/tachys/src/view/tuples.rs +++ b/tachys/src/view/tuples.rs @@ -38,7 +38,7 @@ where async fn resolve(self) -> Self::AsyncOutput {} - fn dry_resolve(&self) {} + fn dry_resolve(&mut self) {} } impl AddAnyAttr for () @@ -136,7 +136,7 @@ where (self.0.resolve().await,) } - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { self.0.dry_resolve(); } } @@ -260,7 +260,7 @@ macro_rules! impl_view_for_tuples { ) } - fn dry_resolve(&self) { + fn dry_resolve(&mut self) { #[allow(non_snake_case)] let ($first, $($ty,)*) = self; $first.dry_resolve();