arith_wrappers 0.2.0

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.
Documentation
1
2
3
4
5
6
7
8
9
10
use crate::consts::msg;
use thiserror::Error;

pub type Result<T, E = Error> = std::result::Result<T, E>;

#[derive(Clone, Debug, Error, PartialEq)]
pub enum Error {
    #[error("{}: {}", msg::ERR_INVALID_INT_REPR, 0)]
    InvalidIntRepr(#[from] std::num::ParseIntError),
}