#[doc(hidden)]
pub mod internal {
use std::fmt::{Debug, Write};
pub struct FormatWrapper<'a, T: ?Sized>(pub &'a T);
impl<T: Debug + ?Sized> FormatWrapper<'_, T> {
#[track_caller]
pub fn __googletest_write_expr_value(&self, output: &mut dyn Write, expr_label: &str) {
write!(output, "\n {} = {:?},", expr_label, self.0)
.expect("Formatting to String should never fail");
}
}
pub trait FormatNonDebugFallback {
fn __googletest_write_expr_value(&self, output: &mut dyn Write, expr_label: &str);
}
impl<T: ?Sized> FormatNonDebugFallback for FormatWrapper<'_, T> {
#[track_caller]
fn __googletest_write_expr_value(&self, output: &mut dyn Write, expr_label: &str) {
write!(output, "\n {expr_label} does not implement Debug,")
.expect("Formatting to String should never fail");
}
}
#[macro_export]
macro_rules! __googletest__write_expr_value(
($output:expr, $expr_str:expr, $value:expr $(,)?) => {
{
use $crate::fmt::internal::FormatNonDebugFallback as _;
$crate::fmt::internal::FormatWrapper(&$value)
.__googletest_write_expr_value(&mut $output, $expr_str)
}
}
);
pub use __googletest__write_expr_value;
}