#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

#2790 in Rust patterns

Download history 223/week @ 2024-03-13 996/week @ 2024-03-20 328/week @ 2024-03-27 458/week @ 2024-04-03 192/week @ 2024-04-10 178/week @ 2024-04-17 159/week @ 2024-04-24 315/week @ 2024-05-01 177/week @ 2024-05-08 200/week @ 2024-05-15 211/week @ 2024-05-22 219/week @ 2024-05-29 217/week @ 2024-06-05 184/week @ 2024-06-12 221/week @ 2024-06-19 182/week @ 2024-06-26

855 downloads per month
Used in elf2uf2-rs

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