From 55054597d177c129b74fceeb753eae7ffa5793aa Mon Sep 17 00:00:00 2001 From: Michael Pfaff Date: Sat, 1 Jul 2023 11:21:37 -0400 Subject: [PATCH] Move Sized bound to the IntoContext trait and add with_caller method --- src/context.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) 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 {