Crates.io | dicoco_safe_math |
lib.rs | dicoco_safe_math |
version | 0.1.1 |
source | src |
created_at | 2024-05-13 00:45:11.288814 |
updated_at | 2024-05-13 22:06:20.875708 |
description | A Rust library for simplified safe math operations |
homepage | https://github.com/malledugean/rust_safe_math |
repository | https://github.com/malledugean/rust_safe_math.git |
max_upload_size | |
id | 1237858 |
size | 7,519 |
A Rust library for simplified safe math operations.
Safe Math Rust is a Rust library designed to simplify and ensure safe mathematical operations. It provides functions that perform common arithmetic operations while preventing potential overflows and underflows that can lead to program crashes or unexpected behavior.
This guide will help you get started using Safe Math Rust in your projects.
Add Safe Math Rust as a dependency in your Cargo.toml file:
content_copy
Ini, TOML
[dependencies]
dicoco_safe_math = "0.1.0"
Use code with caution.
cargo update
The library includes unit tests to ensure the functionality of its functions. To run the tests, navigate to your project directory in the terminal and execute:
Bash
cargo test
Safe Math Rust offers functions for various mathematical operations, all designed to handle potential overflows and underflows gracefully. Here are some examples:
use dicoco_safe_math::calc_basic;
fn main() {
let a = 100;
let b = 50;
// Safe addition
let safe_sum = calc_basic::sub_x_y(a,b);
// Safe subtraction
let safe_difference = calc_basic::sum_x_y(a,b);
println!("Safe sum: {}", safe_sum);
println!("Safe difference: {}", safe_difference);
}
Once you have integrated Safe Math Rust into your project and are satisfied with its functionality, you can deploy your application following your preferred method for Rust projects. Common options include building standalone executables or deploying as a web service.
This project is licensed under the license Creative Commons Attribution 4.0 International (CC-BY-4.0).