Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Monadic-Cat/mice

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Archived

mice has been merged into the project I wrote it for: mbot. I intend to publish further versions, if any, under the AGPLv3+.

docs.rs

mice, messing with dice

This is a simple crate for evaluating dice expressions. It will receive features as I desire, or as are contributed if I happen to be so lucky.

Without further ado, here's some usage:

use mice::roll;

println!("{}", roll("2d6 + 3")?);

println!("{}", roll("2d6 + 3")?.total());

let result = roll("2d6 + 3")?;
println!("{}\n{}", result, result.total());

The parser accepts an arbitrary number of terms in a dice expression.

use mice::roll;
println!("{}", roll("9d8 + 4d2 - 5 - 8d7")?);

Panicking from this crate is considered a serious bug. Please submit an Issue on this project's GitHub repo if it manages to do that, and please describe the usage that it panicked from.

There is one known unavoidable panic that affects this crate. Out of memory. If there isn't enough memory for an allocation, mice will panic. I hope you understand.

To avoid this fate when exposing mice to potentially untrusted users, there exists the util::roll_capped function. If more control is required, use expose::tuple_vec in combination with the builder::RollBuilder::with_tuples method. Both of these things are reexported by the prelude module.