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
|
||||
}
|
||||
|
||||
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<Detail> {
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue