diff --git a/src/context.rs b/src/context.rs index 95d69f7..04fd567 100644 --- a/src/context.rs +++ b/src/context.rs @@ -37,8 +37,13 @@ impl Context { &mut self.extra } - pub fn push_extra(&mut self, detail: Detail) { - self.extra.push(detail); + pub fn push_extra(&mut self, detail: impl IntoContext) { + let detail = detail.into_context(); + if detail.extra.is_empty() { + self.extra.push(detail.detail); + } else { + self.extra.push(Detail::Context(detail.into())); + } } pub fn pop_extra(&mut self) -> Option { @@ -177,12 +182,7 @@ impl IntoContext for Context { #[track_caller] #[inline] fn with(mut self, other: impl IntoContext) -> Self { - let other = other.into_context(); - if other.extra.is_empty() { - self.extra.push(other.detail); - } else { - self.extra.push(Detail::Context(other.into())); - } + self.push_extra(other); self } }