pub trait LogError {
// Required method
fn log_err(self) -> Self;
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T, E: Display> LogError for Result<T, E>
Implementation of LogError for Result<T, E> to simplify the logging of errors for calculations
that can fail.
impl<T, E: Display> LogError for Result<T, E>
Implementation of LogError for Result<T, E> to simplify the logging of errors for calculations
that can fail.
§Examples
use scl_lib::LogError;
fn error_fn() -> Result<(), String> {
Err("Error Message!".to_string())
}
fn success_fn() -> Result<(), String> {
Ok(())
}
// Writes the error message to the log output
let _ = error_fn().log_err();
// Writes nothing for Ok(()) results
let _ = success_fn().log_err();