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

Turbopack: impl<T: ValueDebugFormat> Value<T> #69961

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Changes from 1 commit
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
16 changes: 15 additions & 1 deletion turbopack/crates/turbo-tasks/src/value.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
use std::{fmt::Debug, marker::PhantomData, ops::Deref};

use anyhow::Result;
use serde::{Deserialize, Serialize};

use crate::SharedReference;
use crate::{
debug::{ValueDebugFormat, ValueDebugString},
ReadRef, SharedReference,
};

/// Pass a value by value (`Value<Xxx>`) instead of by reference (`Vc<Xxx>`).
///
Expand Down Expand Up @@ -38,6 +42,16 @@ impl<T: Default> Default for Value<T> {
}
}

impl<T: ValueDebugFormat> Value<T> {
pub async fn dbg(&self) -> Result<ReadRef<ValueDebugString>> {
self.inner
.value_debug_format(usize::MAX)
.try_to_value_debug_string()
.await?
.await
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe also add dbg_depth for consistency


/// Pass a value by value (`Value<Xxx>`) instead of by reference (`Vc<Xxx>`).
///
/// Doesn't require serialization, and won't be stored in the persistent cache
Expand Down
Loading