diff --git a/tachys/src/reactive_graph/suspense.rs b/tachys/src/reactive_graph/suspense.rs index f918cdbd34..43dc5e538b 100644 --- a/tachys/src/reactive_graph/suspense.rs +++ b/tachys/src/reactive_graph/suspense.rs @@ -27,7 +27,7 @@ use reactive_graph::{ use std::{ cell::RefCell, fmt::Debug, - future::Future, + future::{Future, IntoFuture}, mem, pin::Pin, rc::Rc, @@ -115,11 +115,15 @@ impl ToAnySubscriber for SuspendSubscriber { impl Suspend { /// Creates a new suspended view. - pub fn new(fut: impl Future + Send + 'static) -> Self { + pub fn new(fut: Fut) -> Self + where + Fut: IntoFuture, + Fut::IntoFuture: Send + 'static, + { let subscriber = SuspendSubscriber::new(); let any_subscriber = subscriber.to_any_subscriber(); - let inner = - any_subscriber.with_observer(|| Box::pin(ScopedFuture::new(fut))); + let inner = any_subscriber + .with_observer(|| Box::pin(ScopedFuture::new(fut.into_future()))); Self { subscriber, inner } } }