Crates.io | overf |
lib.rs | overf |
version | |
source | src |
created_at | 2024-11-12 15:41:48.539738+00 |
updated_at | 2025-04-07 10:47:51.027212+00 |
description | Customize overflow behavior in mathematical operations. |
homepage | https://github.com/makcandrov/overf |
repository | https://github.com/makcandrov/overf |
max_upload_size | |
id | 1445088 |
Cargo.toml error: | TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Define the overflow behavior of mathematical operations within blocks of code. This library provides the macros checked!
, overflowing!
, saturating!
, propagating!
and default!
, enabling you to easily manage overflow in nested contexts.
use overf::{checked, overflowing, saturating, default};
fn main() {
checked! {
let result = 1usize + 1usize;
let sum = default! { 2usize + 2usize }; // Use default behavior
let difference = 5usize - 3usize;
// Nested blocks
saturating! {
let total = 100u8 - 200u8;
}
}
overflowing! {
let result = 1usize + usize::MAX;
}
}
default!
macro to reset the overflow behavior back to the default.Add overf
to your Cargo.toml
:
[dependencies]
overf = "0.1"
Or run the following command:
cargo add overf