Crates.io | arith_wrappers |
lib.rs | arith_wrappers |
version | 0.2.0 |
source | src |
created_at | 2021-01-31 04:13:44.81359 |
updated_at | 2022-04-16 11:21:37.503564 |
description | Rust's `std` offers the [`Wrapping`](std::num::Wrapping) type for "intentionally wrapping" arithmetic, but curiously does not provide analagous implementations for intentionally saturating, checked, overflowing or panicking arithmetic. This crate addresses these missing wrappers as well as re-exports `std`'s [`Wrapping`](std::num::Wrapping) type for completeness and consistency. |
homepage | |
repository | https://github.com/u007d/arith_wrappers |
max_upload_size | |
id | 348753 |
size | 25,140 |
Rust's std
offers the Wrapping
type for "intentionally
wrapping" arithmetic, but curiously does not provide analogous implementations for intentionally saturating, checked,
overflowing or panicking arithmetic. This crate addresses these missing wrappers as well as exports an alternative to
std
's Wrapping
, providing a consistent interface across
all wrappers in this crate as well as some benefits like trait
-enforced access to T::MIN
and T::MAX
where T
implements any of the wrappers defined in this crate.
Without these wrappers, performing correct arithmetic is verbose, error-prone and pedantic, leading to ignoring the problems altogether or hard-to-maintain implementations.
This crate is at a very early pre-alpha stage of implementation and should be considered a PoC.
Licensed under either:
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.