throwing 0.1.1

Create explicit errors easily with a handy macro
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use std::num::ParseIntError;

use throwing_macros::throws;

#[throws(type BadReverseInt = ParseIntError as ParseNormalIntError)]
fn parse_int_reversed(string: &str) -> u64 {
    let string: String = string.chars().rev().collect();
    Ok(string.parse()?)
}

fn main() {
    match parse_int_reversed("owt") {
        Ok(n) => println!("{n}"),
        Err(BadReverseInt::ParseNormalIntError(e)) => println!("{e}"),
    }
}