Crate logchop

Crate logchop 

Source
Expand description

Log your Result and Option chains with inline methods.

First, import all traits:

use logchop::*;

This will extend Option and Result with new methods. Now you can turn:

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

into

return maybe_something.debug_none("Nothing found!")

๐Ÿ˜—๐ŸคŒ

The full list of methods exposed are available on the respective types

Traitsยง

OptionLogFormatter
Augment Option types with log methods that can print abitrary representations of wrapped values. If the type being wrapped implements Debug, you may be able to use OptionLogger instead.
OptionLogger
Augment Option types with log methods that can print Debug representations of wrapped values. If the type being logged does not implement Debug, use OptionLogFormatter instead.
ResultLogFormatter
Augment Result types with log methods that can print abitrary representations of wrapped values. If the type being logged implements Debug, you may be able to use ResultLogger instead.
ResultLogger
Augment Result types with log methods that can print debug representations of wrapped values. If the wrapped Ok or Err types do not implement Debug, use ResultLogFormatter instead.