Crates.io | peak-result |
lib.rs | peak-result |
version | 1.0.1 |
source | src |
created_at | 2022-10-31 02:10:25.805836 |
updated_at | 2023-10-25 13:50:00.801299 |
description | A simple trait that extends the standard Result enum to allow you to run some code in case of error or success. |
homepage | https://github.com/FaveroFerreira/peak-result |
repository | |
max_upload_size | |
id | 701767 |
size | 8,223 |
This is a simple trait
that extends the standard Result enum to allow you to run some code in case of error or success.
This crate exists because I find it annoying that it's needed to use map_err
or map
so that I can log the results from my functions. However, maybe people find this issue annoying too, and wish to extend upon this basic functionality that peak-error
provides.
[dependencies]
peak-result = "1.0.1"
use peak_result::Peak;
async fn main() {
// using `peak_err`
let result = some_function_that_returns_result()
.peak_err(|e| tracing::error!("function failed: {e:?}"));
// using `peak_ok`
let result = some_function_that_returns_result()
.peak_ok(|it| tracing::info!("function succeeded: {it:?}"));
}
Take a look at our contributing guide if you wish to contribute.
This project is licensed under the MIT license.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in peak-result
by you, shall be licensed as MIT, without any additional terms or conditions.