Move Sized bound to the IntoContext trait and add with_caller method

This commit is contained in:
Michael Pfaff 2023-07-01 11:21:37 -04:00
parent 457328945c
commit 55054597d1
Signed by: michael
GPG Key ID: CF402C4A012AA9D4
1 changed files with 8 additions and 5 deletions

View File

@ -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 {