move core result into core utils

Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
Jason Volk 2024-10-24 01:31:30 +00:00 committed by strawberry
parent 5cb0a5f676
commit c769fcc347
12 changed files with 2 additions and 3 deletions

View file

@ -0,0 +1,24 @@
use std::fmt::Display;
use tracing::Level;
use super::Result;
use crate::error;
pub trait LogErr<T, E: Display> {
#[must_use]
fn err_log(self, level: Level) -> Self;
#[must_use]
fn log_err(self) -> Self
where
Self: Sized,
{
self.err_log(Level::ERROR)
}
}
impl<T, E: Display> LogErr<T, E> for Result<T, E> {
#[inline]
fn err_log(self, level: Level) -> Self { self.inspect_err(|error| error::inspect_log_level(&error, level)) }
}