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§
Source§impl StrengthReducedU32
impl StrengthReducedU32
Sourcepub fn new(divisor: u32) -> Self
pub fn new(divisor: u32) -> 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 StrengthReducedU32
impl Clone for StrengthReducedU32
Source§fn clone(&self) -> StrengthReducedU32
fn clone(&self) -> StrengthReducedU32
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 moreSource§impl Debug for StrengthReducedU32
impl Debug for StrengthReducedU32
Source§impl Div<StrengthReducedU32> for u32
impl Div<StrengthReducedU32> for u32
Source§impl Rem<StrengthReducedU32> for u32
impl Rem<StrengthReducedU32> for u32
impl Copy for StrengthReducedU32
Auto Trait Implementations§
impl Freeze for StrengthReducedU32
impl RefUnwindSafe for StrengthReducedU32
impl Send for StrengthReducedU32
impl Sync for StrengthReducedU32
impl Unpin for StrengthReducedU32
impl UnwindSafe for StrengthReducedU32
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more