binius_utils/formatting.rs
1// Copyright 2025 Irreducible Inc.
2
3/// A macro to implement the `Debug` trait for a given struct or type using JSON serialization.
4#[macro_export]
5macro_rules! impl_debug_with_json {
6 ($name:ident) => {
7 impl std::fmt::Debug for $name {
8 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
9 let json = serde_json::to_string(self).map_err(|_| std::fmt::Error)?;
10 write!(f, "{}", json)
11 }
12 }
13 };
14 () => {};
15}