diff --git a/dynatos/src/element_dyn_attr.rs b/dynatos/src/element_dyn_attr.rs index c533ee4..7957f1c 100644 --- a/dynatos/src/element_dyn_attr.rs +++ b/dynatos/src/element_dyn_attr.rs @@ -3,7 +3,8 @@ // Imports use { crate::ObjectAttachEffect, - dynatos_reactive::{Derived, Effect, Signal, SignalWith}, + dynatos_reactive::{Derived, Effect, Signal, SignalWith, WithDefault}, + dynatos_router::QuerySignal, dynatos_util::{TryOrReturnExt, WeakRef}, }; @@ -142,23 +143,14 @@ where } // TODO: Allow impl for `impl SignalGet` -impl WithDynAttr for Signal -where - T: WithDynAttr, -{ - fn with_attr(&self, f: F) -> O - where - F: FnOnce(Option<&str>) -> O, - { - self.with(|text| text.with_attr(f)) - } -} - -impl WithDynAttr for Derived -where - T: WithDynAttr, - F: ?Sized, -{ +#[duplicate::duplicate_item( + Generics Ty; + [T] [Signal where T: WithDynAttr]; + [T, F] [Derived where T: WithDynAttr, F: ?Sized]; + [T] [QuerySignal where T: WithDynAttr]; + [S, T] [WithDefault where S:SignalWith>, T: WithDynAttr]; +)] +impl WithDynAttr for Ty { fn with_attr(&self, f: F2) -> O where F2: FnOnce(Option<&str>) -> O, @@ -196,19 +188,13 @@ impl DynAttrPred for bool { } // TODO: Allow impl for `impl SignalGet` -impl DynAttrPred for Signal -where - T: DynAttrPred, -{ - fn eval(&self) -> bool { - self.with(T::eval) - } -} - -impl DynAttrPred for Derived -where - T: DynAttrPred, -{ +#[duplicate::duplicate_item( + Generics Ty; + [T] [Signal where T: DynAttrPred]; + [T, F] [Derived where T: DynAttrPred, F: ?Sized]; + [S, T] [WithDefault where S:SignalWith>, T: DynAttrPred]; +)] +impl DynAttrPred for Ty { fn eval(&self) -> bool { self.with(T::eval) } diff --git a/dynatos/src/node_dyn_text.rs b/dynatos/src/node_dyn_text.rs index 536871e..b006296 100644 --- a/dynatos/src/node_dyn_text.rs +++ b/dynatos/src/node_dyn_text.rs @@ -113,22 +113,14 @@ where } // TODO: Allow impl for `impl SignalGet` -impl WithDynText for Signal -where - T: WithDynText, -{ - fn with_text(&self, f: F) -> O - where - F: FnOnce(Option<&str>) -> O, - { - self.with(|text| text.with_text(f)) - } -} -impl WithDynText for Derived -where - T: WithDynText, - F: ?Sized, -{ +#[duplicate::duplicate_item( + Generics Ty; + [T] [Signal where T: WithDynText]; + [T, F] [Derived where T: WithDynText, F: ?Sized]; + [T] [QuerySignal where T: WithDynText]; + [S, T] [WithDefault where S:SignalWith>, T: WithDynText]; +)] +impl WithDynText for Ty { fn with_text(&self, f: F2) -> O where F2: FnOnce(Option<&str>) -> O, @@ -136,26 +128,3 @@ where self.with(|text| text.with_text(f)) } } -impl WithDynText for QuerySignal -where - T: WithDynText, -{ - fn with_text(&self, f: F) -> O - where - F: FnOnce(Option<&str>) -> O, - { - self.with(|text| text.with_text(f)) - } -} -impl WithDynText for WithDefault -where - S: SignalWith>, - T: WithDynText, -{ - fn with_text(&self, f: F) -> O - where - F: FnOnce(Option<&str>) -> O, - { - self.with(|text| text.with_text(f)) - } -} diff --git a/dynatos/src/object_dyn_prop.rs b/dynatos/src/object_dyn_prop.rs index 59a0f29..7e4dc2c 100644 --- a/dynatos/src/object_dyn_prop.rs +++ b/dynatos/src/object_dyn_prop.rs @@ -140,36 +140,14 @@ impl ToDynProp for Ty { } // TODO: Allow impl for `impl SignalGet` -impl ToDynProp for Signal -where - T: ToDynProp, -{ - fn to_prop(&self) -> Option { - self.with(|prop| prop.to_prop()) - } -} -impl ToDynProp for Derived -where - T: ToDynProp, - F: ?Sized, -{ - fn to_prop(&self) -> Option { - self.with(|prop| prop.to_prop()) - } -} -impl ToDynProp for QuerySignal -where - T: ToDynProp, -{ - fn to_prop(&self) -> Option { - self.with(|prop| prop.to_prop()) - } -} -impl ToDynProp for WithDefault -where - S: SignalWith>, - T: ToDynProp, -{ +#[duplicate::duplicate_item( + Generics Ty; + [T] [Signal where T: ToDynProp]; + [T, F] [Derived where T: ToDynProp, F: ?Sized]; + [T] [QuerySignal where T: ToDynProp]; + [S, T] [WithDefault where S:SignalWith>, T: ToDynProp]; +)] +impl ToDynProp for Ty { fn to_prop(&self) -> Option { self.with(|prop| prop.to_prop()) }