[][src]Crate mice

mice, messing with dice

The heading obviates the need for a body.

This crate is written primarily for my own usage, and will likely obtain extensions related to games that I play.

Some basic usage:

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.

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

Modules

builder

A builder for rolling stuff. This API affords more flexibility than the basic one. Specifically, it allows a user to provide their own RNG in the place of the default ThreadRng. See rand issue #313 for why this is sometimes necessary.

prelude

Re-export of primary useful things in mice, so it's easier to get started using it. Just use mice::prelude::* and you're off to the races!

util

Nice to have utilities that aren't core to dice manipulation itself, just handy for some reason.

Structs

ExpressionResult

The result of evaluating a dice expression.

FormatOptions

Formatting options for dice expressions. Necessary for stability of user facing output, which is this library's primary concern.

Enums

RollError

Most general mice error type.

Functions

roll

Evaluate a dice expression! This function takes the usual dice expression format, and allows an arbitrary number of terms.

roll_tuples

Roll and sum a slice of tuples, in the form provided by this function's complement: tuple_vec

tuple_vec

Get a Vec of tuples of the form: (number of dice, number of faces)