diff --git a/src/context.rs b/src/context.rs index b9b444f..fedc31b 100644 --- a/src/context.rs +++ b/src/context.rs @@ -93,16 +93,19 @@ impl fmt::Display for Detail { } } -pub trait IntoContext { +pub trait IntoContext: Sized { fn into_context(self) -> Context; #[inline(always)] - fn with(self, other: impl IntoContext) -> Context - where - Self: Sized, - { + fn with(self, other: impl IntoContext) -> Context { self.into_context().with(other) } + + #[inline(always)] + #[track_caller] + fn with_caller(self) -> Context { + self.with(Location::caller()) + } } impl IntoContext for Context {