logchop

Crates.iologchop
lib.rslogchop
version0.1.2
sourcesrc
created_at2021-01-31 20:01:04.315819
updated_at2021-02-03 03:01:23.523673
descriptionLog your `Result` and `Option` chains with inline methods.
homepagehttps://github.com/arusahni/logchop
repositoryhttps://github.com/arusahni/logchop
max_upload_size
id348995
size32,120
Aru Sahni (arusahni)

documentation

README

Latest version

LogChop

It's better than bad, it's good!

Log your Result and Option chains with inline methods.

Turn

match maybe_something {
    Some(x) => Some(x),
    None => {
        debug!("Nothing found!");
        None
    }
}.

into

maybe_something.debug_none("Nothing found!")

This becomes handy when you start chaining from results

use logchop::*;

parse_id_string(id_str)
    .trace_ok("Found id")
    .debug_err("Couldn't parse ID")
    .map_or_else(|id| get_widget_by_id(id), |_| get_default_widget())
    .info_ok_format(|widget| format!("Found widget: {}", widget.name))
# Sucessful parse result
[trace] Found id: 12
[info ] Found widget: chainsaw

# Error parsing result
[debug] Couldn't parse ID: Invalid format
[info ] Found widget: concilation prize

Say goodbye to unnecessary blocks!

Documentation

Available on Docs.rs.

Installation and Usage

Add the following to your Cargo.toml:

logchop = "0.1"

and then import traits: use logchop::*

Commit count: 7

cargo fmt