Skip to main content

NumOpResult

Enum NumOpResult 

Source
pub enum NumOpResult<T> {
    Valid(T),
    Error(NumOpError),
}
Expand description

Result of a mathematical operation on two numeric types.

In order to prevent overflow we provide a custom result type that is similar to the normal core::result::Result but implements mathematical operations (e.g. core::ops::Add) so that math operations can be chained ergonomically. This is very similar to how NaN works.

NumOpResult is a monadic type that contains Valid and Error (similar to Ok and Err). It supports a subset of functions similar to Result (e.g. unwrap).

§Examples

The NumOpResult type provides protection against overflow and div-by-zero.

§Overflow protection

// Example UTXO value.
let a1 = Amount::from_sat(1_000_000)?;
// And another value from some other UTXO.
let a2 = Amount::from_sat(765_432)?;
// Just an example (typically one would calculate fee using weight and fee rate).
let fee = Amount::from_sat(1_00)?;
// The amount we want to send.
let spend = Amount::from_sat(1_200_000)?;

// We can error if the change calculation overflows.
//
// For example if the `spend` value comes from the user and the `change` value is later
// used then overflow here could be an attack vector.
let _change = (a1 + a2 - spend - fee).into_result().expect("handle this error");

// Or if we control all the values and know they are sane we can just `unwrap`.
let _change = (a1 + a2 - spend - fee).unwrap();
// `NumOpResult` also implements `expect`.
let _change = (a1 + a2 - spend - fee).expect("we know values don't overflow");

§Divide-by-zero (overflow in Div or Rem)

In some instances one may wish to differentiate div-by-zero from overflow.

// Two amounts that will be added to calculate the max fee.
let a = Amount::from_sat(123).expect("valid amount");
let b = Amount::from_sat(467).expect("valid amount");
// Fee rate for transaction.
let fee_rate = FeeRate::from_sat_per_vb(1);

// Somewhat contrived example to show addition operator chained with division.
let max_fee = a + b;
let _fee = match max_fee / fee_rate {
    NumOpResult::Valid(fee) => fee,
    NumOpResult::Error(e) if e.is_div_by_zero() => {
        // Do something when div by zero.
        return Err(e);
    },
    NumOpResult::Error(e) => {
        // We separate div-by-zero from overflow in case it needs to be handled separately.
        //
        // This branch could be hit since `max_fee` came from some previous calculation. And if
        // an input to that calculation was from the user then overflow could be an attack vector.
        return Err(e);
    }
};

Variants§

§

Valid(T)

Result of a successful mathematical operation.

§

Error(NumOpError)

Result of an unsuccessful mathematical operation.

Implementations§

Source§

impl<T> NumOpResult<T>

Source

pub fn map<U, F: FnOnce(T) -> U>(self, op: F) -> NumOpResult<U>

Maps a NumOpResult<T> to NumOpResult<U> by applying a function to a contained NumOpResult::Valid value, leaving a NumOpResult::Error value untouched.

Source§

impl<T: Debug> NumOpResult<T>

Source

pub fn expect(self, msg: &str) -> T

Returns the contained valid numeric type, consuming self.

§Panics

Panics with msg if the numeric result is an Error.

Source

pub fn unwrap(self) -> T

Returns the contained valid numeric type, consuming self.

§Panics

Panics if the numeric result is an Error.

Source

pub fn unwrap_err(self) -> NumOpError

Returns the contained error, consuming self.

§Panics

Panics if the numeric result is valid.

Source

pub fn unwrap_or(self, default: T) -> T

Returns the contained Some value or a provided default.

Arguments passed to unwrap_or are eagerly evaluated; if you are passing the result of a function call, it is recommended to use unwrap_or_else, which is lazily evaluated.

Source

pub fn unwrap_or_else<F>(self, f: F) -> T
where F: FnOnce() -> T,

Returns the contained Some value or computes it from a closure.

Source

pub fn ok(self) -> Option<T>

Converts this NumOpResult to an Option<T>.

Source

pub fn into_result(self) -> Result<T, NumOpError>

Converts this NumOpResult to a Result<T, NumOpError>.

Source

pub fn and_then<F>(self, op: F) -> Self
where F: FnOnce(T) -> Self,

Calls op if the numeric result is Valid, otherwise returns the Error value of self.

Source

pub fn is_valid(&self) -> bool

Returns true if the numeric result is valid.

Source

pub fn is_error(&self) -> bool

Returns true if the numeric result is invalid.

Trait Implementations§

Source§

impl<'a> Add<&'a NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Add<NumOpResult<Amount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&NumOpResult<Amount>> for Amount

Source§

type Output = <Amount as Add<NumOpResult<Amount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a> Add<&'a NumOpResult<SignedAmount>> for &SignedAmount

Source§

type Output = <SignedAmount as Add<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<SignedAmount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<&NumOpResult<SignedAmount>> for SignedAmount

Source§

type Output = <SignedAmount as Add<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<SignedAmount>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<&'a NumOpResult<T>> for &NumOpResult<T>
where T: Copy + Add<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&NumOpResult<T>> for NumOpResult<T>
where T: Copy + Add<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &NumOpResult<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<'a, T> Add<&'a T> for &NumOpResult<T>
where T: Copy + Add<NumOpResult<T>, Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Add<T>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<&T> for NumOpResult<T>
where T: Copy + Add<NumOpResult<T>, Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Add<T>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: &T) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Add<NumOpResult<Amount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<NumOpResult<Amount>> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<NumOpResult<SignedAmount>> for &SignedAmount

Source§

type Output = <SignedAmount as Add<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<SignedAmount>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add<NumOpResult<SignedAmount>> for SignedAmount

Source§

type Output = NumOpResult<SignedAmount>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<SignedAmount>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<NumOpResult<T>> for &NumOpResult<T>
where T: Copy + Add<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Add>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: NumOpResult<T>) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<T> for &NumOpResult<T>
where T: Copy + Add<NumOpResult<T>, Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Add<T>>::Output

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add<T> for NumOpResult<T>
where T: Copy + Add<NumOpResult<T>, Output = NumOpResult<T>>,

Source§

type Output = NumOpResult<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> Self::Output

Performs the + operation. Read more
Source§

impl<T> Add for NumOpResult<T>
where T: Copy + Add<Output = NumOpResult<T>>,

Source§

type Output = NumOpResult<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign<Amount> for NumOpResult<Amount>

Source§

fn add_assign(&mut self, rhs: Amount)

Performs the += operation. Read more
Source§

impl AddAssign<SignedAmount> for NumOpResult<SignedAmount>

Source§

fn add_assign(&mut self, rhs: SignedAmount)

Performs the += operation. Read more
Source§

impl<T: AddAssign> AddAssign<T> for NumOpResult<T>

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl AddAssign for NumOpResult<Amount>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl AddAssign for NumOpResult<SignedAmount>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<T: AddAssign + Copy> AddAssign for NumOpResult<T>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<'a, T: Arbitrary<'a>> Arbitrary<'a> for NumOpResult<T>

Available on crate feature arbitrary only.
Source§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
Source§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
Source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
Source§

impl<T: Clone> Clone for NumOpResult<T>

Source§

fn clone(&self) -> NumOpResult<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
Source§

impl<T: Debug> Debug for NumOpResult<T>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a> Div<&'a FeeRate> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<FeeRate>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&FeeRate> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<FeeRate>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NumOpResult<FeeRate>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NumOpResult<FeeRate>> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NumOpResult<FeeRate>> for Amount

Source§

type Output = <Amount as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NumOpResult<FeeRate>> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NumOpResult<Weight>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a NumOpResult<Weight>> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NumOpResult<Weight>> for Amount

Source§

type Output = <Amount as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&NumOpResult<Weight>> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a Weight> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<Weight>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&Weight> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<Weight>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a i64> for &NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Div<i64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &i64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&i64> for NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Div<i64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &i64) -> Self::Output

Performs the / operation. Read more
Source§

impl<'a> Div<&'a u64> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<u64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<&u64> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<u64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: &u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<FeeRate> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<FeeRate>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<FeeRate> for NumOpResult<Amount>

Source§

type Output = NumOpResult<Weight>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: FeeRate) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<FeeRate>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<FeeRate>> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<NumOpResult<FeeRate>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<FeeRate>> for Amount

Source§

type Output = NumOpResult<Weight>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<FeeRate>> for NumOpResult<Amount>

Source§

type Output = NumOpResult<Weight>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<Weight>> for &Amount

Source§

type Output = <Amount as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<Weight>> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<NumOpResult<Weight>>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<Weight>> for Amount

Source§

type Output = NumOpResult<FeeRate>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<NumOpResult<Weight>> for NumOpResult<Amount>

Source§

type Output = NumOpResult<FeeRate>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Weight> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<Weight>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<Weight> for NumOpResult<Amount>

Source§

type Output = NumOpResult<FeeRate>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: Weight) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i64> for &NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Div<i64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<i64> for NumOpResult<SignedAmount>

Source§

type Output = NumOpResult<SignedAmount>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: i64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u64> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Div<u64>>::Output

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl Div<u64> for NumOpResult<Amount>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: u64) -> Self::Output

Performs the / operation. Read more
Source§

impl DivAssign<&i64> for NumOpResult<SignedAmount>

Source§

fn div_assign(&mut self, rhs: &i64)

Performs the /= operation. Read more
Source§

impl DivAssign<&u64> for NumOpResult<Amount>

Source§

fn div_assign(&mut self, rhs: &u64)

Performs the /= operation. Read more
Source§

impl DivAssign<i64> for NumOpResult<SignedAmount>

Source§

fn div_assign(&mut self, rhs: i64)

Performs the /= operation. Read more
Source§

impl DivAssign<u64> for NumOpResult<Amount>

Source§

fn div_assign(&mut self, rhs: u64)

Performs the /= operation. Read more
Source§

impl From<&Amount> for NumOpResult<Amount>

Source§

fn from(a: &Amount) -> Self

Converts to this type from the input type.
Source§

impl From<&SignedAmount> for NumOpResult<SignedAmount>

Source§

fn from(a: &SignedAmount) -> Self

Converts to this type from the input type.
Source§

impl From<Amount> for NumOpResult<Amount>

Source§

fn from(a: Amount) -> Self

Converts to this type from the input type.
Source§

impl From<SignedAmount> for NumOpResult<SignedAmount>

Source§

fn from(a: SignedAmount) -> Self

Converts to this type from the input type.
Source§

impl<'a> Mul<&'a FeeRate> for &NumOpResult<Weight>

Source§

type Output = <NumOpResult<Weight> as Mul<FeeRate>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &FeeRate) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&FeeRate> for NumOpResult<Weight>

Source§

type Output = <NumOpResult<Weight> as Mul<FeeRate>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &FeeRate) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a NumOpResult<Amount>> for &u64

Source§

type Output = <u64 as Mul<NumOpResult<Amount>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&NumOpResult<Amount>> for u64

Source§

type Output = <u64 as Mul<NumOpResult<Amount>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a NumOpResult<FeeRate>> for &NumOpResult<Weight>

Source§

type Output = <NumOpResult<Weight> as Mul<NumOpResult<FeeRate>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a NumOpResult<FeeRate>> for &Weight

Source§

type Output = <Weight as Mul<NumOpResult<FeeRate>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&NumOpResult<FeeRate>> for NumOpResult<Weight>

Source§

type Output = <NumOpResult<Weight> as Mul<NumOpResult<FeeRate>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&NumOpResult<FeeRate>> for Weight

Source§

type Output = <Weight as Mul<NumOpResult<FeeRate>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a NumOpResult<SignedAmount>> for &i64

Source§

type Output = <i64 as Mul<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<SignedAmount>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&NumOpResult<SignedAmount>> for i64

Source§

type Output = <i64 as Mul<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<SignedAmount>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a NumOpResult<Weight>> for &FeeRate

Source§

type Output = <FeeRate as Mul<NumOpResult<Weight>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a NumOpResult<Weight>> for &NumOpResult<FeeRate>

Source§

type Output = <NumOpResult<FeeRate> as Mul<NumOpResult<Weight>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&NumOpResult<Weight>> for FeeRate

Source§

type Output = <FeeRate as Mul<NumOpResult<Weight>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&NumOpResult<Weight>> for NumOpResult<FeeRate>

Source§

type Output = <NumOpResult<FeeRate> as Mul<NumOpResult<Weight>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a Weight> for &NumOpResult<FeeRate>

Source§

type Output = <NumOpResult<FeeRate> as Mul<Weight>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Weight) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&Weight> for NumOpResult<FeeRate>

Source§

type Output = <NumOpResult<FeeRate> as Mul<Weight>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &Weight) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a i64> for &NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Mul<i64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &i64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&i64> for NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Mul<i64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &i64) -> Self::Output

Performs the * operation. Read more
Source§

impl<'a> Mul<&'a u64> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Mul<u64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<&u64> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Mul<u64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: &u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<FeeRate> for &NumOpResult<Weight>

Source§

type Output = <NumOpResult<Weight> as Mul<FeeRate>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: FeeRate) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<FeeRate> for NumOpResult<Weight>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: FeeRate) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<Amount>> for &u64

Source§

type Output = <u64 as Mul<NumOpResult<Amount>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<Amount>> for u64

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<FeeRate>> for &NumOpResult<Weight>

Source§

type Output = <NumOpResult<Weight> as Mul<NumOpResult<FeeRate>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<FeeRate>> for &Weight

Source§

type Output = <Weight as Mul<NumOpResult<FeeRate>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<FeeRate>> for NumOpResult<Weight>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<FeeRate>> for Weight

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<FeeRate>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<SignedAmount>> for &i64

Source§

type Output = <i64 as Mul<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<SignedAmount>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<SignedAmount>> for i64

Source§

type Output = NumOpResult<SignedAmount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<SignedAmount>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<Weight>> for &FeeRate

Source§

type Output = <FeeRate as Mul<NumOpResult<Weight>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<Weight>> for &NumOpResult<FeeRate>

Source§

type Output = <NumOpResult<FeeRate> as Mul<NumOpResult<Weight>>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<Weight>> for FeeRate

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<NumOpResult<Weight>> for NumOpResult<FeeRate>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: NumOpResult<Weight>) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Weight> for &NumOpResult<FeeRate>

Source§

type Output = <NumOpResult<FeeRate> as Mul<Weight>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Weight) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<Weight> for NumOpResult<FeeRate>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Weight) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i64> for &NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Mul<i64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<i64> for NumOpResult<SignedAmount>

Source§

type Output = NumOpResult<SignedAmount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: i64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u64> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Mul<u64>>::Output

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl Mul<u64> for NumOpResult<Amount>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: u64) -> Self::Output

Performs the * operation. Read more
Source§

impl MulAssign<&i64> for NumOpResult<SignedAmount>

Source§

fn mul_assign(&mut self, rhs: &i64)

Performs the *= operation. Read more
Source§

impl MulAssign<&u64> for NumOpResult<Amount>

Source§

fn mul_assign(&mut self, rhs: &u64)

Performs the *= operation. Read more
Source§

impl MulAssign<i64> for NumOpResult<SignedAmount>

Source§

fn mul_assign(&mut self, rhs: i64)

Performs the *= operation. Read more
Source§

impl MulAssign<u64> for NumOpResult<Amount>

Source§

fn mul_assign(&mut self, rhs: u64)

Performs the *= operation. Read more
Source§

impl<T: PartialEq> PartialEq for NumOpResult<T>

Source§

fn eq(&self, other: &NumOpResult<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'a> Rem<&'a i64> for &NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Rem<i64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &i64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&i64> for NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Rem<i64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &i64) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Rem<&'a u64> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Rem<u64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &u64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<&u64> for NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Rem<u64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: &u64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<i64> for &NumOpResult<SignedAmount>

Source§

type Output = <NumOpResult<SignedAmount> as Rem<i64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: i64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<i64> for NumOpResult<SignedAmount>

Source§

type Output = NumOpResult<SignedAmount>

The resulting type after applying the % operator.
Source§

fn rem(self, modulus: i64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<u64> for &NumOpResult<Amount>

Source§

type Output = <NumOpResult<Amount> as Rem<u64>>::Output

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: u64) -> Self::Output

Performs the % operation. Read more
Source§

impl Rem<u64> for NumOpResult<Amount>

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the % operator.
Source§

fn rem(self, modulus: u64) -> Self::Output

Performs the % operation. Read more
Source§

impl<'a> Sub<&'a NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Sub<NumOpResult<Amount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&NumOpResult<Amount>> for Amount

Source§

type Output = <Amount as Sub<NumOpResult<Amount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a> Sub<&'a NumOpResult<SignedAmount>> for &SignedAmount

Source§

type Output = <SignedAmount as Sub<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<SignedAmount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<&NumOpResult<SignedAmount>> for SignedAmount

Source§

type Output = <SignedAmount as Sub<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<SignedAmount>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<&'a NumOpResult<T>> for &NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<&NumOpResult<T>> for NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &NumOpResult<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<'a, T> Sub<&'a T> for &NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Sub<T>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<&T> for NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Sub<T>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: &T) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<NumOpResult<Amount>> for &Amount

Source§

type Output = <Amount as Sub<NumOpResult<Amount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<NumOpResult<Amount>> for Amount

Source§

type Output = NumOpResult<Amount>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<Amount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<NumOpResult<SignedAmount>> for &SignedAmount

Source§

type Output = <SignedAmount as Sub<NumOpResult<SignedAmount>>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<SignedAmount>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub<NumOpResult<SignedAmount>> for SignedAmount

Source§

type Output = NumOpResult<SignedAmount>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<SignedAmount>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<NumOpResult<T>> for &NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Sub>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: NumOpResult<T>) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<T> for &NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = <NumOpResult<T> as Sub<T>>::Output

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub<T> for NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = NumOpResult<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> Self::Output

Performs the - operation. Read more
Source§

impl<T> Sub for NumOpResult<T>
where T: Copy + Sub<Output = NumOpResult<T>>,

Source§

type Output = NumOpResult<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Self) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign<Amount> for NumOpResult<Amount>

Source§

fn sub_assign(&mut self, rhs: Amount)

Performs the -= operation. Read more
Source§

impl SubAssign<SignedAmount> for NumOpResult<SignedAmount>

Source§

fn sub_assign(&mut self, rhs: SignedAmount)

Performs the -= operation. Read more
Source§

impl<T: SubAssign> SubAssign<T> for NumOpResult<T>

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl SubAssign for NumOpResult<Amount>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl SubAssign for NumOpResult<SignedAmount>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<T: SubAssign + Copy> SubAssign for NumOpResult<T>

Source§

fn sub_assign(&mut self, rhs: Self)

Performs the -= operation. Read more
Source§

impl<'a> Sum<&'a NumOpResult<Amount>> for NumOpResult<Amount>

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<'a> Sum<&'a NumOpResult<SignedAmount>> for NumOpResult<SignedAmount>

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = &'a Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for NumOpResult<Amount>

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl Sum for NumOpResult<SignedAmount>

Source§

fn sum<I>(iter: I) -> Self
where I: Iterator<Item = Self>,

Takes an iterator and generates Self from the elements by “summing up” the items.
Source§

impl<T: Copy> Copy for NumOpResult<T>

Source§

impl<T: Eq> Eq for NumOpResult<T>

Source§

impl<T> StructuralPartialEq for NumOpResult<T>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<T> UnsafeUnpin for NumOpResult<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for NumOpResult<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> 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.