#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

#2481 in Rust patterns

Download history 161/week @ 2024-08-22 163/week @ 2024-08-29 274/week @ 2024-09-05 274/week @ 2024-09-12 221/week @ 2024-09-19 211/week @ 2024-09-26 170/week @ 2024-10-03 213/week @ 2024-10-10 192/week @ 2024-10-17 250/week @ 2024-10-24 250/week @ 2024-10-31 279/week @ 2024-11-07 401/week @ 2024-11-14 459/week @ 2024-11-21 284/week @ 2024-11-28 267/week @ 2024-12-05

1,472 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