Skip to main content

Checked

Struct Checked 

pub struct Checked<T>(pub CtOption<T>);
Expand description

Provides intentionally-checked arithmetic on T.

Internally this leverages the CtOption type from the subtle crate in order to handle overflows.

Tuple Fields§

§0: CtOption<T>

Implementations§

§

impl<T> Checked<T>

pub fn new(val: T) -> Checked<T>

Create a new checked arithmetic wrapper for the given value.

Trait Implementations§

§

impl Add<&Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
§

fn add(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
§

impl Add<&Checked<Limb>> for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
§

fn add(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
§

impl<const LIMBS: usize> Add<&Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
§

fn add(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
§

impl<const LIMBS: usize> Add<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
§

fn add(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
§

impl Add<Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
§

fn add(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
§

impl<const LIMBS: usize> Add<Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
§

fn add(self, rhs: Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
§

impl Add for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the + operator.
§

fn add(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the + operation. Read more
§

impl<const LIMBS: usize> Add for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the + operator.
§

fn add(self, rhs: Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the + operation. Read more
§

impl AddAssign<&Checked<Limb>> for Checked<Limb>

§

fn add_assign(&mut self, other: &Checked<Limb>)

Performs the += operation. Read more
§

impl<const LIMBS: usize> AddAssign<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

§

fn add_assign(&mut self, other: &Checked<Uint<LIMBS>>)

Performs the += operation. Read more
§

impl AddAssign for Checked<Limb>

§

fn add_assign(&mut self, other: Checked<Limb>)

Performs the += operation. Read more
§

impl<const LIMBS: usize> AddAssign for Checked<Uint<LIMBS>>

§

fn add_assign(&mut self, other: Checked<Uint<LIMBS>>)

Performs the += operation. Read more
§

impl<T> Clone for Checked<T>
where T: Clone,

§

fn clone(&self) -> Checked<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> ConditionallySelectable for Checked<T>

§

fn conditional_select( a: &Checked<T>, b: &Checked<T>, choice: Choice, ) -> Checked<T>

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
§

impl<T> ConstantTimeEq for Checked<T>
where T: ConstantTimeEq,

§

fn ct_eq(&self, rhs: &Checked<T>) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
§

impl<T> Debug for Checked<T>
where T: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T> Default for Checked<T>
where T: Default,

§

fn default() -> Checked<T>

Returns the “default value” for a type. Read more
§

impl<T> From<Checked<T>> for CtOption<T>

§

fn from(checked: Checked<T>) -> CtOption<T>

Converts to this type from the input type.
§

impl<T> From<CtOption<T>> for Checked<T>

§

fn from(ct_option: CtOption<T>) -> Checked<T>

Converts to this type from the input type.
§

impl Mul<&Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
§

fn mul(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
§

impl Mul<&Checked<Limb>> for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
§

fn mul(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<&Checked<Uint<HLIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
§

fn mul(self, rhs: &Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<&Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
§

fn mul(self, rhs: &Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
§

impl Mul<Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
§

fn mul(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<Checked<Uint<HLIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
§

fn mul(self, rhs: Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
§

impl<const LIMBS: usize, const HLIMBS: usize> Mul<Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the * operator.
§

fn mul(self, rhs: Checked<Uint<HLIMBS>>) -> Checked<Uint<LIMBS>>

Performs the * operation. Read more
§

impl Mul for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the * operator.
§

fn mul(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the * operation. Read more
§

impl MulAssign<&Checked<Limb>> for Checked<Limb>

§

fn mul_assign(&mut self, other: &Checked<Limb>)

Performs the *= operation. Read more
§

impl<const LIMBS: usize, const HLIMBS: usize> MulAssign<&Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

§

fn mul_assign(&mut self, other: &Checked<Uint<HLIMBS>>)

Performs the *= operation. Read more
§

impl<const LIMBS: usize, const HLIMBS: usize> MulAssign<Checked<Uint<HLIMBS>>> for Checked<Uint<LIMBS>>

§

fn mul_assign(&mut self, other: Checked<Uint<HLIMBS>>)

Performs the *= operation. Read more
§

impl MulAssign for Checked<Limb>

§

fn mul_assign(&mut self, other: Checked<Limb>)

Performs the *= operation. Read more
§

impl Sub<&Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
§

fn sub(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
§

impl Sub<&Checked<Limb>> for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
§

fn sub(self, rhs: &Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
§

impl<const LIMBS: usize> Sub<&Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
§

fn sub(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
§

impl<const LIMBS: usize> Sub<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
§

fn sub(self, rhs: &Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
§

impl Sub<Checked<Limb>> for &Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
§

fn sub(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
§

impl<const LIMBS: usize> Sub<Checked<Uint<LIMBS>>> for &Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
§

fn sub(self, rhs: Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
§

impl Sub for Checked<Limb>

§

type Output = Checked<Limb>

The resulting type after applying the - operator.
§

fn sub(self, rhs: Checked<Limb>) -> Checked<Limb>

Performs the - operation. Read more
§

impl<const LIMBS: usize> Sub for Checked<Uint<LIMBS>>

§

type Output = Checked<Uint<LIMBS>>

The resulting type after applying the - operator.
§

fn sub(self, rhs: Checked<Uint<LIMBS>>) -> Checked<Uint<LIMBS>>

Performs the - operation. Read more
§

impl SubAssign<&Checked<Limb>> for Checked<Limb>

§

fn sub_assign(&mut self, other: &Checked<Limb>)

Performs the -= operation. Read more
§

impl<const LIMBS: usize> SubAssign<&Checked<Uint<LIMBS>>> for Checked<Uint<LIMBS>>

§

fn sub_assign(&mut self, other: &Checked<Uint<LIMBS>>)

Performs the -= operation. Read more
§

impl SubAssign for Checked<Limb>

§

fn sub_assign(&mut self, other: Checked<Limb>)

Performs the -= operation. Read more
§

impl<const LIMBS: usize> SubAssign for Checked<Uint<LIMBS>>

§

fn sub_assign(&mut self, other: Checked<Uint<LIMBS>>)

Performs the -= operation. Read more
§

impl<T> Copy for Checked<T>
where T: Copy,

Auto Trait Implementations§

§

impl<T> Freeze for Checked<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for Checked<T>
where T: RefUnwindSafe,

§

impl<T> Send for Checked<T>
where T: Send,

§

impl<T> Sync for Checked<T>
where T: Sync,

§

impl<T> Unpin for Checked<T>
where T: Unpin,

§

impl<T> UnwindSafe for Checked<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

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

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T, Rhs, Output> GroupOps<Rhs, Output> for T
where T: Add<Rhs, Output = Output> + Sub<Rhs, Output = Output> + AddAssign<Rhs> + SubAssign<Rhs>,

§

impl<T, Rhs, Output> GroupOpsOwned<Rhs, Output> for T
where T: for<'r> GroupOps<&'r Rhs, Output>,

§

impl<T, Rhs, Output> ScalarMul<Rhs, Output> for T
where T: Mul<Rhs, Output = Output> + MulAssign<Rhs>,

§

impl<T, Rhs, Output> ScalarMulOwned<Rhs, Output> for T
where T: for<'r> ScalarMul<&'r Rhs, Output>,