Allow passing any IntoContext to push_extra
This commit is contained in:
parent
71385c9e19
commit
c20ceb332a
|
@ -37,8 +37,13 @@ impl Context {
|
||||||
&mut self.extra
|
&mut self.extra
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn push_extra(&mut self, detail: Detail) {
|
pub fn push_extra(&mut self, detail: impl IntoContext) {
|
||||||
self.extra.push(detail);
|
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<Detail> {
|
pub fn pop_extra(&mut self) -> Option<Detail> {
|
||||||
|
@ -177,12 +182,7 @@ impl IntoContext for Context {
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
#[inline]
|
#[inline]
|
||||||
fn with(mut self, other: impl IntoContext) -> Self {
|
fn with(mut self, other: impl IntoContext) -> Self {
|
||||||
let other = other.into_context();
|
self.push_extra(other);
|
||||||
if other.extra.is_empty() {
|
|
||||||
self.extra.push(other.detail);
|
|
||||||
} else {
|
|
||||||
self.extra.push(Detail::Context(other.into()));
|
|
||||||
}
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue