pub struct Modulus { /* private fields */ }Expand description
A counter space of 2^bits values.
Implementations§
Source§impl Modulus
impl Modulus
Sourcepub const fn new<const BITS: u32>() -> Self
pub const fn new<const BITS: u32>() -> Self
The BITS-wide space; a width outside 1..=63 is a compile error.
Sourcepub const fn try_new(bits: u32) -> Option<Self>
pub const fn try_new(bits: u32) -> Option<Self>
The bits-wide space, or None when bits is outside 1..=63.
Sourcepub const fn half(self) -> u64
pub const fn half(self) -> u64
Half the space: the largest forward distance signed
reports as positive.
Sourcepub const fn add_signed(self, a: u64, delta: i64) -> u64
pub const fn add_signed(self, a: u64, delta: i64) -> u64
(a + delta) mod 2^bits, delta of either sign; always in the space.
Sourcepub const fn forward(self, from: u64, to: u64) -> u64
pub const fn forward(self, from: u64, to: u64) -> u64
The forward distance from from to to: (to - from) mod 2^bits.
Sourcepub const fn signed(self, from: u64, to: u64) -> i64
pub const fn signed(self, from: u64, to: u64) -> i64
The shorter signed distance from from to to, in (-half, half]:
crossing the wrap forward is a small positive step, stepping back
across it a small negative one; exactly half the space apart is
+half.
Sourcepub const fn is_tie(self, a: u64, b: u64) -> bool
pub const fn is_tie(self, a: u64, b: u64) -> bool
a and b are exactly half the space apart, so neither precedes the
other.
Sourcepub const fn leq(self, a: u64, b: u64) -> bool
pub const fn leq(self, a: u64, b: u64) -> bool
a precedes or equals b; false at the half-space tie.
Sourcepub const fn geq(self, a: u64, b: u64) -> bool
pub const fn geq(self, a: u64, b: u64) -> bool
a follows or equals b; false at the half-space tie.
Trait Implementations§
impl Copy for Modulus
impl Eq for Modulus
impl StructuralPartialEq for Modulus
Auto Trait Implementations§
impl Forget for Modulus
impl Freeze for Modulus
impl Move for Modulus
impl RefUnwindSafe for Modulus
impl Send for Modulus
impl Sync for Modulus
impl Unpin for Modulus
impl UnsafeUnpin for Modulus
impl UnwindSafe for Modulus
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