pub struct Fin {
pub val: usize,
pub bound: usize,
}Expand description
A bounded integer value in [0, n). Host-side representation of Fin n.
Fields§
§val: usizeThe numeric value.
bound: usizeThe (exclusive) upper bound.
Implementations§
Source§impl Fin
impl Fin
Sourcepub fn new(val: usize, bound: usize) -> Option<Self>
pub fn new(val: usize, bound: usize) -> Option<Self>
Create a new Fin if val < bound, otherwise None.
Sourcepub fn complement(self) -> Self
pub fn complement(self) -> Self
Return the additive inverse (complement): bound - 1 - val.
Sourcepub fn add(self, other: Self) -> Option<Self>
pub fn add(self, other: Self) -> Option<Self>
Add two Fin values with the same bound (modular).
Sourcepub fn mul(self, other: Self) -> Option<Self>
pub fn mul(self, other: Self) -> Option<Self>
Multiply two Fin values with the same bound (modular).
Trait Implementations§
Source§impl Ord for Fin
impl Ord for Fin
Source§impl PartialOrd for Fin
impl PartialOrd for Fin
impl Copy for Fin
impl Eq for Fin
impl StructuralPartialEq for Fin
Auto Trait Implementations§
impl Freeze for Fin
impl RefUnwindSafe for Fin
impl Send for Fin
impl Sync for Fin
impl Unpin for Fin
impl UnsafeUnpin for Fin
impl UnwindSafe for Fin
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