Skip to content

Commit

Permalink
ready to publish
Browse files Browse the repository at this point in the history
  • Loading branch information
ninomerlino committed Feb 22, 2024
1 parent d075865 commit ede4749
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/.idea
10 changes: 9 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
use log::error;
//!# unwrap_or_log
//! This crate adds functions to all [`std::results::Result<T,E>`] where E implements [`std::error::Error`] by implementing the trait [`Loggable<T>`] for them
//!
//! The trait [`Loggable<T>`] exposes three functions:
//!
//! - `unwrap_or_log`: Returns the contained value [`T`] or logs the error and panics
//! - `log_if_error`: Log the error and returns itself
//! - `ok_or_log`: Converts [`std::result::Result<T, E>`] to an [`Option<T>`] and logs the error if present
use log::error;
///Trait exposing the unwrap_or_log interface
pub trait Loggable<T> {
///This function should try to unwrap `self` and if it fails it logs the error and panic
Expand Down

0 comments on commit ede4749

Please sign in to comment.