#assert #convert #error

bin+lib assert_into

For when writing .try_into().unwrap() feels too long

5 stable releases

1.1.0 Oct 22, 2020
1.0.3 Oct 1, 2020

#2531 in Rust patterns

Download history 215/week @ 2024-07-22 171/week @ 2024-07-29 268/week @ 2024-08-05 250/week @ 2024-08-12 180/week @ 2024-08-19 155/week @ 2024-08-26 219/week @ 2024-09-02 310/week @ 2024-09-09 237/week @ 2024-09-16 219/week @ 2024-09-23 179/week @ 2024-09-30 173/week @ 2024-10-07 205/week @ 2024-10-14 227/week @ 2024-10-21 269/week @ 2024-10-28 250/week @ 2024-11-04

979 downloads per month
Used in 2 crates

MIT/Apache

6KB

assert_into

For when writing .try_into().unwrap() feels too long.

use assert_into::AssertInto;

fn main() {
    let a: u32 = (-1i32).assert_into();
}

Gives you: thread 'main' panicked at '-1 is out of range for type u32: TryFromIntError(())', src\main.rs:4:26

No runtime deps