#clippy #utilities #panic #overflow #utils

clippy-utilities

Utilities funtions for clippy fixing

2 unstable releases

0.2.0 Jun 13, 2022
0.1.0 Feb 19, 2022

#836 in Math

Download history 560/week @ 2023-10-20 422/week @ 2023-10-27 434/week @ 2023-11-03 364/week @ 2023-11-10 379/week @ 2023-11-17 500/week @ 2023-11-24 483/week @ 2023-12-01 451/week @ 2023-12-08 437/week @ 2023-12-15 390/week @ 2023-12-22 461/week @ 2023-12-29 563/week @ 2024-01-05 565/week @ 2024-01-12 637/week @ 2024-01-19 564/week @ 2024-01-26 396/week @ 2024-02-02

2,255 downloads per month
Used in 4 crates

MIT license

9KB
187 lines

Cast and Overflow utilities

This utility lib helps for type casting and integer operation overflow checking. The following code block shows examples:

let a: u64 = 10;
let b: i64 = a.numeric_cast();
let a = 1.overflow_add(1);

For the first example, as conversion is not perfect for slicently lossy conversion while try_from and try_into are better. However they're too verbose in most cases, so we wrap it in the cast method and make it panic while these try_xxx methods failed.

For the second example, rust std lib provides overflow checking methods such as overflowing_add. The methods provided in this lib are one step futher, panicing when any overflow happens.


lib.rs:

Traits for datenlord.

Dependencies

~22KB