dnd

Crates.iodnd
lib.rsdnd
version0.2.0
created_at2025-06-20 03:32:51.568364+00
updated_at2025-06-23 06:06:04.29046+00
descriptionD&D 5e types and common mechanics
homepage
repositoryhttp://crates.lurey.io/dnd
max_upload_size
id1719088
size74,503
admins (github:crates-lurey-io:admins)

documentation

README

dnd

D&D 5e types and common mechanics.

Test Crates.io Version codecov

This crate provides types and common mechanics used in Dungeons & Dragons 5th Edition (D&D 5e).

Getting Started

To use this crate, add it to your Cargo.toml:

cargo add dnd

You can then import the necessary modules in your Rust code:

use dnd::core::{AbilityScore, AbilityModifier, Level, ProficiencyBonus};

let strength = AbilityScore::new(16);
let modifier = AbilityModifier::from(strength);
let level = Level::new(5);
let proficiency_bonus = ProficiencyBonus::from(level);

assert_eq!(modifier.value(), 3);
assert_eq!(proficiency_bonus.value(), 3);

Features

This crate has optional features and is no_std-compatible:

  • std: Enabled by default; it includes the standard library. If you want to use this crate in a no_std environment, you can disable this feature:

    dnd = { version = "...", default-features = false }
    
  • serde: Enables serialization and deserialization using serde. This feature is optional and can be enabled by adding the serde feature in your Cargo.toml:

    dnd = { version = "...", features = ["serde"] }
    

Contributing

This project uses just to run commands the same way as the CI:

  • cargo just check to check formatting and lints.
  • cargo just coverage to generate and preview code coverage.
  • cargo just doc to generate and preview docs.
  • cargo just test to run tests.

For a full list of commands, see the Justfile.

Commit count: 0

cargo fmt