Browse Source

add debug impl

Evan Almloff 1 year ago
parent
commit
3242fc9e88
1 changed files with 7 additions and 1 deletions
  1. 7 1
      packages/signals/src/lib.rs

+ 7 - 1
packages/signals/src/lib.rs

@@ -1,6 +1,6 @@
 use std::{
     cell::{Ref, RefMut},
-    fmt::Display,
+    fmt::{Debug, Display},
     ops::{Add, Div, Mul, Sub},
     sync::Arc,
 };
@@ -92,6 +92,12 @@ impl<T: Display + 'static> Display for Signal<T> {
     }
 }
 
+impl<T: Debug + 'static> Debug for Signal<T> {
+    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        self.with(|v| Debug::fmt(v, f))
+    }
+}
+
 impl<T: Add<Output = T> + Copy + 'static> std::ops::AddAssign<T> for Signal<T> {
     fn add_assign(&mut self, rhs: T) {
         self.set(self.get() + rhs);