throws!
is a macro for easy creation per-function error enums.
```rust
throws!(FileDoubleError = Io(io::Error), Parse(ParseIntError));
fn file_double(path: &str) -> Result
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
.
If you're using cargo, just add throws
to your Cargo.toml
:
```toml [dependencies]
throws = "*" ```
Otherwise, cargo build
, and the rlib will be in your target
directory.
MIT