pub struct Quantity(pub i128);Expand description
数量
Tuple Fields§
§0: i128Implementations§
Source§impl Quantity
impl Quantity
pub const ZERO: Quantity
pub const fn from_raw(raw: i128) -> Quantity
pub const fn raw(self) -> i128
pub fn from_i64(v: i64) -> Quantity
pub fn checked_add(self, o: Quantity) -> Option<Quantity>
pub fn checked_sub(self, o: Quantity) -> Option<Quantity>
Sourcepub fn checked_mul(self, o: Quantity) -> Option<Quantity>
pub fn checked_mul(self, o: Quantity) -> Option<Quantity>
定点乘法:结果 = (a * b) / SCALE
Sourcepub fn checked_div(self, o: Quantity) -> Option<Quantity>
pub fn checked_div(self, o: Quantity) -> Option<Quantity>
定点除法:结果 = (a * SCALE) / b
pub fn is_zero(self) -> bool
pub fn checked_abs(self) -> Option<Quantity>
Trait Implementations§
impl Copy for Quantity
Source§impl<'de> Deserialize<'de> for Quantity
impl<'de> Deserialize<'de> for Quantity
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Quantity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Quantity, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Quantity
Source§impl Ord for Quantity
impl Ord for Quantity
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Quantity
impl PartialOrd for Quantity
Source§impl Serialize for Quantity
impl Serialize for Quantity
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Quantity
Auto Trait Implementations§
impl Forget for Quantity
impl Freeze for Quantity
impl Move for Quantity
impl RefUnwindSafe for Quantity
impl Send for Quantity
impl Sync for Quantity
impl Unpin for Quantity
impl UnsafeUnpin for Quantity
impl UnwindSafe for Quantity
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