2 releases
0.1.1 | May 13, 2024 |
---|---|
0.1.0 | May 13, 2024 |
#338 in Math
8KB
Project Safe Math for Rust
A Rust library for simplified safe math operations.
📝 Table of Contents
🧐 About
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.
🏁 Getting Started
This guide will help you get started using Safe Math Rust in your projects.
Prerequisites
- Rust compiler: Download and install Rust from the official website https://www.rust-lang.org/tools/install.
- Basic understanding of Rust: Familiarity with core Rust concepts like functions, variables, and data types is recommended.
Installing
Add Safe Math Rust as a dependency in your Cargo.toml file:
content_copy
- Run cargo update to install the library.
Ini, TOML
[dependencies]
dicoco_safe_math = "0.1.0"
Use code with caution.
- Run cargo update to install the library.
cargo update
🔧 Running the tests
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
🎈 Usage
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);
}
🚀 Deployment
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.
⛏️ Built Using
- Rust - Rust
📜 License:
This project is licensed under the license Creative Commons Attribution 4.0 International (CC-BY-4.0).
✍️ Authors
- @malledugean - Idea & Initial work
🎉 Acknowledgements
- NearX Rust learning