Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: print inner value in Debug impls #2384

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions leptos_reactive/src/memo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,11 +369,10 @@ where

impl<T> Copy for Memo<T> {}

impl<T> fmt::Debug for Memo<T> {
impl<T: fmt::Debug> fmt::Debug for Memo<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut s = f.debug_struct("Memo");
s.field("id", &self.id);
s.field("ty", &self.ty);
self.with_untracked(|v| s.field("inner", v));
#[cfg(any(debug_assertions, feature = "ssr"))]
s.field("defined_at", &self.defined_at);
s.finish()
Expand Down
10 changes: 4 additions & 6 deletions leptos_reactive/src/signal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,11 +772,10 @@ impl<T> Clone for ReadSignal<T> {

impl<T> Copy for ReadSignal<T> {}

impl<T> fmt::Debug for ReadSignal<T> {
impl<T: fmt::Debug> fmt::Debug for ReadSignal<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut s = f.debug_struct("ReadSignal");
s.field("id", &self.id);
s.field("ty", &self.ty);
self.with_untracked(|v| s.field("inner", v));
#[cfg(any(debug_assertions, feature = "ssr"))]
s.field("defined_at", &self.defined_at);
s.finish()
Expand Down Expand Up @@ -1224,11 +1223,10 @@ impl<T> Clone for RwSignal<T> {

impl<T> Copy for RwSignal<T> {}

impl<T> fmt::Debug for RwSignal<T> {
impl<T: fmt::Debug> fmt::Debug for RwSignal<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut s = f.debug_struct("RwSignal");
s.field("id", &self.id);
s.field("ty", &self.ty);
self.with_untracked(|v| s.field("inner", v));
#[cfg(any(debug_assertions, feature = "ssr"))]
s.field("defined_at", &self.defined_at);
s.finish()
Expand Down
14 changes: 7 additions & 7 deletions leptos_reactive/src/signal_wrappers_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl<T> Clone for Signal<T> {

impl<T> Copy for Signal<T> {}

impl<T> core::fmt::Debug for Signal<T> {
impl<T: core::fmt::Debug> core::fmt::Debug for Signal<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
let mut s = f.debug_struct("Signal");
s.field("inner", &self.inner);
Expand Down Expand Up @@ -458,14 +458,14 @@ impl<T> Clone for SignalTypes<T> {

impl<T> Copy for SignalTypes<T> {}

impl<T> core::fmt::Debug for SignalTypes<T> {
impl<T: core::fmt::Debug> core::fmt::Debug for SignalTypes<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Self::ReadSignal(arg0) => {
f.debug_tuple("ReadSignal").field(arg0).finish()
}
Self::Memo(arg0) => f.debug_tuple("Memo").field(arg0).finish(),
Self::DerivedSignal(_) => f.debug_tuple("DerivedSignal").finish(),
Self::ReadSignal(arg0) => arg0.fmt(f),
Self::Memo(arg0) => arg0.fmt(f),
Self::DerivedSignal(get) => get.with_value(|get| {
f.debug_tuple("DerivedSignal").field(&untrack(get)).finish()
}),
}
}
}
Expand Down
9 changes: 4 additions & 5 deletions leptos_reactive/src/stored_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ impl<T> Clone for StoredValue<T> {

impl<T> Copy for StoredValue<T> {}

impl<T> fmt::Debug for StoredValue<T> {
impl<T: fmt::Debug> fmt::Debug for StoredValue<T> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("StoredValue")
.field("id", &self.id)
.field("ty", &self.ty)
.finish()
self.with_value(|v| {
f.debug_struct("StoredValue").field("inner", v).finish()
})
}
}

Expand Down
Loading