#log #macro #logging

yanked skip-fail

A macro to help skip an iteration in a loop from a Result

1.0.0 Mar 19, 2020

#681 in #log

MIT license

5KB

![GitHub Action Status](https://img.shields.io/github/workflow/status/CanalTP/skip-fail/Continuous Integration)

skip-fail

skip-fail provides a single macro to help ignoring Error that would happen in a loop. See documentation to know more.


lib.rs:

This crate provides a single macro to help skipping a error in a loop, possibly logging it.

For example, imagine you have some code like this.

for string_number in &["1", "2", "three", "4"] {
  let number: u32 = match string_number.parse() {
    Ok(n) => n,
    Err(e) => continue,
  };
}

Then you can use the macro skip_fail! to write like this.

for string_number in &["1", "2", "three", "4"] {
  let number: u32 = skip_fail!(string_number.parse());
}

If you want the error to be logged, you can use the feature log. The logging will be done in WARN level with the standard logging interface provided by log.

Dependencies

~22KB