throws 0.1.2

A macro for easy creation per-function errors.
Documentation
  • Coverage
  • 0%
    0 out of 6 items documented0 out of 0 items with examples
  • Size
  • Source code size: 9.9 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.24 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • limbo-rs/throws
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • XX

Throws

throws! is a macro for easy creation per-function error enums.

Example

throws!(FileDoubleError = Io(io::Error), Parse(ParseIntError));
fn file_double(path: &str) -> Result<i32, FileDoubleError> {
    let mut file = File::open(path)?;
    let mut contents = String::new();

    file.read_to_string(&mut contents)?;
    let n: i32 = contents.trim().parse()?;

    Ok(2 * n)
}

For more, check out the examples directory!

You can run an individual example using cargo run --example example-name.

Installation

If you're using cargo, just add throws to your Cargo.toml:

[dependencies]

throws = "*"

Otherwise, cargo build, and the rlib will be in your target directory.

License

MIT