Skip to content

Commit

Permalink
remove From<T> and add back From<Fn() -> T>
Browse files Browse the repository at this point in the history
  • Loading branch information
mscofield0 committed Dec 18, 2024
1 parent f9533ab commit 105a8e7
Showing 1 changed file with 18 additions and 32 deletions.
50 changes: 18 additions & 32 deletions reactive_graph/src/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,30 +643,36 @@ pub mod read {
}
}

impl<T: Send + Sync + 'static> From<T> for ArcSignal<T, SyncStorage> {
impl<F, T> From<F> for Signal<T>
where
F: Fn() -> T + Send + Sync + 'static,
T: Send + Sync + 'static,
{
#[track_caller]
fn from(value: T) -> Self {
ArcSignal::stored(value)
fn from(value: F) -> Self {
Self::derive(value)
}
}

impl<T> From<T> for Signal<T>
impl<F, T> From<F> for Signal<T, LocalStorage>
where
T: Send + Sync + 'static,
F: Fn() -> T + 'static,
T: 'static,
{
#[track_caller]
fn from(value: T) -> Self {
Self::stored(value)
fn from(value: F) -> Self {
Self::derive_local(value)
}
}

impl<T> From<T> for Signal<T, LocalStorage>
impl<F, T> From<F> for ArcSignal<T, SyncStorage>
where
T: 'static,
F: Fn() -> T + Send + Sync + 'static,
T: Send + Sync + 'static,
{
#[track_caller]
fn from(value: T) -> Self {
Self::stored_local(value)
fn from(value: F) -> Self {
Self::derive(value)
}
}

Expand Down Expand Up @@ -893,26 +899,6 @@ pub mod read {
}
}

impl<T> From<T> for Signal<Option<T>>
where
T: Send + Sync + 'static,
{
#[track_caller]
fn from(value: T) -> Self {
Signal::stored(Some(value))
}
}

impl<T> From<T> for Signal<Option<T>, LocalStorage>
where
T: 'static,
{
#[track_caller]
fn from(value: T) -> Self {
Signal::stored_local(Some(value))
}
}

impl<T> From<Signal<T>> for Signal<Option<T>>
where
T: Clone + Send + Sync + 'static,
Expand Down Expand Up @@ -1611,7 +1597,7 @@ pub mod read {

impl From<&str> for MaybeProp<String> {
fn from(value: &str) -> Self {
Self(Some(Signal::from(Some(value.to_string()))))
Self(Some(Signal::stored(Some(value.to_string()))))
}
}

Expand Down

0 comments on commit 105a8e7

Please sign in to comment.