It's better than bad, it's good!
Log your Result
and Option
chains with inline methods.
Turn
rust
match maybe_something {
Some(x) => Some(x),
None => {
debug!("Nothing found!");
None
}
}.
into
rust
maybe_something.debug_none("Nothing found!")
This becomes handy when you start chaining from results
```rust use logchop::*;
parseidstring(idstr) .traceok("Found id") .debugerr("Couldn't parse ID") .maporelse(|id| getwidgetbyid(id), || getdefaultwidget()) .infook_format(|widget| format!("Found widget: {}", widget.name)) ```
```
[trace] Found id: 12 [info ] Found widget: chainsaw
[debug] Couldn't parse ID: Invalid format [info ] Found widget: concilation prize ```
Say goodbye to unnecessary blocks!
Add the following to your Cargo.toml
:
toml
logchop = "0.1"
and then import traits: use logchop::*