pub struct StrengthReducedU32 { /* private fields */ }
Expand description

Implements unsigned division and modulo via mutiplication and shifts.

Creating a an instance of this struct is more expensive than a single division, but if the division is repeated, this version will be several times faster than naive division.

Implementations

Creates a new divisor instance.

If possible, avoid calling new() from an inner loop: The intended usage is to create an instance of this struct outside the loop, and use it for divison and remainders inside the loop.

Panics:

Panics if divisor is 0

Simultaneous truncated integer division and modulus. Returns (quotient, remainder).

Retrieve the value used to create this struct

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
The resulting type after applying the / operator.
Performs the / operation. Read more
The resulting type after applying the % operator.
Performs the % operation. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.