mistake 0.1.1

An error handling crate for functions that produce multiple errors
Documentation
  • Coverage
  • 0%
    0 out of 7 items documented0 out of 2 items with examples
  • Size
  • Source code size: 37.96 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.29 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • rehwinkel/mistake
    2 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rehwinkel

mistake

An error handling crate for functions that produce multiple errors

Example

use mistake::Mistake::{self, Fine};

fn count_valid_strings(strings: Vec<String>) -> Mistake<i32, std::num::ParseIntError> {
    let mut errors = Vec::new();
    let mut count = 0;
    for s in strings {
        let value: Option<i32> = Mistake::from(s.parse::<i32>()).to_option(&mut errors);
        if value.is_some() {
            count += 1;
        }
    }
    Fine(count, errors)
}

Use cases

In some situations it is not desirable to abort execution as soon as an error occurs (e.g. a compiler would usually produce more than one error at once). In situations like those, this crate can be used to aggregate multiple errors before returning, thus being able to give more meaningful error information to the user.