Struct strength_reduce::StrengthReducedU16
source · pub struct StrengthReducedU16 { /* 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§
source§impl StrengthReducedU16
impl StrengthReducedU16
sourcepub fn new(divisor: u16) -> Self
pub fn new(divisor: u16) -> Self
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
Trait Implementations§
source§impl Clone for StrengthReducedU16
impl Clone for StrengthReducedU16
source§fn clone(&self) -> StrengthReducedU16
fn clone(&self) -> StrengthReducedU16
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read more