#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

#2460 in Rust patterns

Download history 401/week @ 2024-11-14 459/week @ 2024-11-21 284/week @ 2024-11-28 348/week @ 2024-12-05 409/week @ 2024-12-12 303/week @ 2024-12-19 324/week @ 2024-12-26 329/week @ 2025-01-02 270/week @ 2025-01-09 290/week @ 2025-01-16 262/week @ 2025-01-23 257/week @ 2025-01-30 376/week @ 2025-02-06 296/week @ 2025-02-13 302/week @ 2025-02-20 340/week @ 2025-02-27

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