pub trait DiceRoller: Send + Sync {
// Required method
fn roll_individual(&self, count: u32, sides: u32) -> Vec<i64>;
// Provided method
fn roll(&self, count: u32, sides: u32) -> i64 { ... }
}Expand description
A pluggable dice-rolling backend.
Implement this trait to substitute the default rand-based roller with a
deterministic stub in tests, or a custom RNG in production.
Required Methods§
Provided Methods§
Sourcefn roll(&self, count: u32, sides: u32) -> i64
fn roll(&self, count: u32, sides: u32) -> i64
Roll and return the total (sum of all individual results).
§Overflow behaviour
The default implementation uses checked addition and saturates to
i64::MAX on overflow. This is a limitation of the i64 return
type — callers that need proper error propagation should use
Self::roll_individual and sum the results with
[crate::vm::eval::checked_sum_rolls] instead.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".