From 54855e44b4a91383314cf15e08bfed99362f9a9e Mon Sep 17 00:00:00 2001 From: Folyd Date: Sat, 1 May 2021 10:23:44 +0800 Subject: [PATCH] core: impl `Value` for `&mut T` where `T: Value` --- tracing-core/src/field.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tracing-core/src/field.rs b/tracing-core/src/field.rs index ae2b44dc2f..29d4709107 100644 --- a/tracing-core/src/field.rs +++ b/tracing-core/src/field.rs @@ -428,6 +428,19 @@ where } } +impl<'a, T: ?Sized> crate::sealed::Sealed for &'a mut T where T: Value + crate::sealed::Sealed + 'a {} + +impl<'a, T: ?Sized> Value for &'a mut T +where + T: Value + 'a, +{ + fn record(&self, key: &Field, visitor: &mut dyn Visit) { + // Don't use `(*self).record(key, visitor)`, otherwise would + // cause stack overflow due to `unconditional_recursion`. + T::record(self, key, visitor) + } +} + impl<'a> crate::sealed::Sealed for fmt::Arguments<'a> {} impl<'a> Value for fmt::Arguments<'a> {