#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

#2462 in Rust patterns

Download history 291/week @ 2024-10-27 246/week @ 2024-11-03 293/week @ 2024-11-10 424/week @ 2024-11-17 362/week @ 2024-11-24 329/week @ 2024-12-01 404/week @ 2024-12-08 398/week @ 2024-12-15 270/week @ 2024-12-22 313/week @ 2024-12-29 324/week @ 2025-01-05 293/week @ 2025-01-12 262/week @ 2025-01-19 244/week @ 2025-01-26 335/week @ 2025-02-02 309/week @ 2025-02-09

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