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ยง
- Option
LogFormatter - Augment
Option
types with log methods that can print abitrary representations of wrapped values. If the type being wrapped implementsDebug
, you may be able to useOptionLogger
instead. - Option
Logger - Augment
Option
types with log methods that can printDebug
representations of wrapped values. If the type being logged does not implementDebug
, useOptionLogFormatter
instead. - Result
LogFormatter - Augment
Result
types with log methods that can print abitrary representations of wrapped values. If the type being logged implementsDebug
, you may be able to useResultLogger
instead. - Result
Logger - Augment
Result
types with log methods that can print debug representations of wrapped values. If the wrappedOk
orErr
types do not implementDebug
, useResultLogFormatter
instead.