Trait Modulus

Source
pub trait Modulus<T>: Integer + Unsigned
where T: TryFrom<Self>, <T as TryFrom<Self>>::Error: Debug,
{ // Provided method fn cast(self) -> T { ... } }
Expand description

Modulus is an unsigned integer that can be cast to some other type T. The purpose is to restrict the modulus to unsigned integers yet allow calculations with signed integers when necessary.

Provided Methods§

Source

fn cast(self) -> T

Cast the modulus to some other type T. Panics if the modulus cannot be converted to T.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<T, M> Modulus<T> for M
where T: TryFrom<M>, <T as TryFrom<M>>::Error: Debug, M: Integer + Unsigned,