Skip to content

Commit

Permalink
core: impl field::Value for Option<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
DCjanus authored and bryanburgers committed Sep 21, 2021
1 parent 27a2ce9 commit 723563f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tracing-core/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ impl<T: fmt::Display> fmt::Display for DisplayValue<T> {

impl<T: fmt::Debug> crate::sealed::Sealed for DebugValue<T> {}

impl<T: fmt::Debug> Value for DebugValue<T>
impl<T> Value for DebugValue<T>
where
T: fmt::Debug,
{
Expand All @@ -540,6 +540,16 @@ impl Value for Empty {
fn record(&self, _: &Field, _: &mut dyn Visit) {}
}

impl<T: Value> crate::sealed::Sealed for Option<T> {}

impl<T: Value> Value for Option<T> {
fn record(&self, key: &Field, visitor: &mut dyn Visit) {
if let Some(v) = &self {
v.record(key, visitor)
}
}
}

// ===== impl Field =====

impl Field {
Expand Down

0 comments on commit 723563f

Please sign in to comment.