clippy-utilities 0.2.0

Utilities funtions for clippy fixing
Documentation
  • Coverage
  • 100%
    12 out of 12 items documented0 out of 0 items with examples
  • Size
  • Source code size: 12.17 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 409.1 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 8s Average build duration of successful builds.
  • all releases: 8s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • datenlord/utilities
    1 4 1
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • rogercloud pwang7 pzheng1025

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.