1 unstable release
new 0.1.0 | Mar 14, 2025 |
---|
#2123 in Parser implementations
17KB
376 lines
Die-Sir
Die-Sir (Dicer) is a dice parser for random dice rolling with support for modifiers through basic math operations
Usage
Add this to your Cargo.toml
:
[dependencies]
die-sir = "0.1.0"
Basic usage example:
use die_sir::evaluate;
fn main() {
let result = evaluate("2d6 + 3".to_string());
match result {
Ok(val) => println!("Result: {}", val),
Err(e) => println!("Error: {}", e),
}
}
Features
- Parse dice expressions (e.g., "2d6", "1d20+5")
- Support for basic arithmetic operations (+, -, *, /, ^)
- Error handling for invalid expressions and number overflow
License
This project is licensed under the MIT License - see the LICENSE file for details
lib.rs
:
DieSir is a library for parsing and evaluating dice expressions as well as basic math expressions.
This crate provides functionality to parse and evaluate dice rolling expressions like "2d6 + 3"
Dependencies
~330KB