1 unstable release

Uses old Rust 2015

0.1.0 Jul 6, 2017

#27 in #roll

MIT license

6KB
73 lines

lib_dice

A dice parsing library uses nom for dice syndax parsing

Usage

Cargo.toml

[dependencies]
lib_dice = { git = "https://github.com/twh2898/lib_dice" }

src/main.rs

extern crate lib_dice;

fn main() {
	let roll_1 = lib_dice::roll(1, 8, 0); // 1d8 + 0
	let roll_2 = lib_dice::roll_from_str("2d6 + 7");
}

Example

$ git clone https://github.com/twh2898/lib_dice.git
$ cd lib_dice
$ cargo run --example demo

The following prompt will start. Close the demo with CTRL + C

Welcome to Dice Line v0.1.0
> 1d8
3
> 3d6 + 8
16

Licence

lib_dice uses the MIT Licence


lib.rs:

A library for parcing dice rolls using nom.

Usage

extern crate lib_dice;
fn main() {
	let roll_1 = lib_dice::roll(1, 8, 0); // 1d8 + 0
	let roll_2 = lib_dice::roll_from_str("2d6 + 7");
}

Dependencies

~1.5MB
~26K SLoC