mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 04:41:02 +00:00
Add ensure-ops family methods (#12967)
* add ensure-ops family methods * fix cargo doc * add EnsureOp and EnsureOpAssign meta traits * move ensure module and ArithmeticError to sp-arithmetic * fix doc examples * reexport ensure module content * ensure mod private * reexport to sp-runtime * fix doc example * remove into(). in doc examples, minor doc changes * remove return value from assign methods * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * Update primitives/arithmetic/src/traits.rs Co-authored-by: Bastian Köcher <git@kchr.de> * cargo fmt * Apply suggestions from code review * ".git/.scripts/fmt.sh" 1 Co-authored-by: Bastian Köcher <git@kchr.de> Co-authored-by: command-bot <>
This commit is contained in:
committed by
GitHub
parent
0a94112c9d
commit
af79220695
@@ -93,9 +93,9 @@ pub use sp_arithmetic::biguint;
|
||||
pub use sp_arithmetic::helpers_128bit;
|
||||
/// Re-export top-level arithmetic stuff.
|
||||
pub use sp_arithmetic::{
|
||||
traits::SaturatedConversion, FixedI128, FixedI64, FixedPointNumber, FixedPointOperand,
|
||||
FixedU128, InnerOf, PerThing, PerU16, Perbill, Percent, Permill, Perquintill, Rational128,
|
||||
Rounding, UpperOf,
|
||||
traits::SaturatedConversion, ArithmeticError, FixedI128, FixedI64, FixedPointNumber,
|
||||
FixedPointOperand, FixedU128, InnerOf, PerThing, PerU16, Perbill, Percent, Permill,
|
||||
Perquintill, Rational128, Rounding, UpperOf,
|
||||
};
|
||||
|
||||
pub use either::Either;
|
||||
@@ -641,28 +641,6 @@ impl From<TokenError> for DispatchError {
|
||||
}
|
||||
}
|
||||
|
||||
/// Arithmetic errors.
|
||||
#[derive(Eq, PartialEq, Clone, Copy, Encode, Decode, Debug, TypeInfo)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
pub enum ArithmeticError {
|
||||
/// Underflow.
|
||||
Underflow,
|
||||
/// Overflow.
|
||||
Overflow,
|
||||
/// Division by zero.
|
||||
DivisionByZero,
|
||||
}
|
||||
|
||||
impl From<ArithmeticError> for &'static str {
|
||||
fn from(e: ArithmeticError) -> &'static str {
|
||||
match e {
|
||||
ArithmeticError::Underflow => "An underflow would occur",
|
||||
ArithmeticError::Overflow => "An overflow would occur",
|
||||
ArithmeticError::DivisionByZero => "Division by zero",
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ArithmeticError> for DispatchError {
|
||||
fn from(e: ArithmeticError) -> DispatchError {
|
||||
Self::Arithmetic(e)
|
||||
|
||||
@@ -33,8 +33,10 @@ use serde::{de::DeserializeOwned, Deserialize, Serialize};
|
||||
use sp_application_crypto::AppKey;
|
||||
pub use sp_arithmetic::traits::{
|
||||
AtLeast32Bit, AtLeast32BitUnsigned, Bounded, CheckedAdd, CheckedDiv, CheckedMul, CheckedShl,
|
||||
CheckedShr, CheckedSub, IntegerSquareRoot, One, SaturatedConversion, Saturating,
|
||||
UniqueSaturatedFrom, UniqueSaturatedInto, Zero,
|
||||
CheckedShr, CheckedSub, Ensure, EnsureAdd, EnsureAddAssign, EnsureDiv, EnsureDivAssign,
|
||||
EnsureFixedPointNumber, EnsureFrom, EnsureInto, EnsureMul, EnsureMulAssign, EnsureOp,
|
||||
EnsureOpAssign, EnsureSub, EnsureSubAssign, IntegerSquareRoot, One, SaturatedConversion,
|
||||
Saturating, UniqueSaturatedFrom, UniqueSaturatedInto, Zero,
|
||||
};
|
||||
use sp_core::{self, storage::StateVersion, Hasher, RuntimeDebug, TypeId};
|
||||
#[doc(hidden)]
|
||||
|
||||
Reference in New Issue
Block a user