rollz 🎲
rollz
is a super-simple Rust crate that allows you to... roll dice! What else would you need from a crate?!
In reality, this crate was born as an experiment for me to understand Rust return type polymorphism and while I was at it, why wouldn't I publish it as a crate for everyone else enjoyment!?
I don't expect this to be particularly useful for real life projects™️, except maybe if you are implementing something that has to do with D&D or similar types of board games.
Yes, this crate implements standard D&D dice set: D4
, D6
, D8
, D10
, D12
and D20
.
Install
To install the library add the following lines to your Cargo.toml
:
[]
= "0"
Or, if you have cargo add
, you can run the following command:
Sample Usage
This is how you would roll a D10
with rollz
:
use *;
use D10;
Or you can also roll multiple dices together, because why not?
use *;
use D6;
More usage examples are available in the examples
folder.
Create your own custom die
Here's an example for you, if you want to build a custom die:
use *;
/// A roll of this guy will always give you 100!
/// Shush ... Don't tell anyone! 🤫
;
Contributing
Everyone is very welcome to contribute to this project. You can contribute just by submitting bugs or suggesting improvements by opening an issue on GitHub.
License
Licensed under MIT License. © Luciano Mammino.