pub struct TokenAmount {
pub token: Token,
pub amount: u128,
}
Expand description
A given amount of token. Can be used for nicely formatted output and token-aware comparison of different amounts.
let token = Token { name: "I❤U", decimals: 8 };
let my_amount = token.amount(100_000_000_000);
assert_eq!(format!("{}", my_amount), "1,000.000 I❤U");
assert_eq!(format!("{:?}", my_amount), "1000.000 I❤U (100,000,000,000)");
Fields§
§token: Token
The token this amount is from.
amount: u128
The amount in the smallest granularity of the token.
Trait Implementations§
source§impl Clone for TokenAmount
impl Clone for TokenAmount
source§fn clone(&self) -> TokenAmount
fn clone(&self) -> TokenAmount
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for TokenAmount
impl Debug for TokenAmount
source§impl Display for TokenAmount
impl Display for TokenAmount
source§impl Hash for TokenAmount
impl Hash for TokenAmount
source§impl Ord for TokenAmount
impl Ord for TokenAmount
source§fn cmp(&self, other: &TokenAmount) -> Ordering
fn cmp(&self, other: &TokenAmount) -> Ordering
1.21.0 · 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
source§impl PartialEq for TokenAmount
impl PartialEq for TokenAmount
source§impl PartialOrd for TokenAmount
impl PartialOrd for TokenAmount
impl Eq for TokenAmount
impl StructuralPartialEq for TokenAmount
Auto Trait Implementations§
impl Freeze for TokenAmount
impl RefUnwindSafe for TokenAmount
impl Send for TokenAmount
impl Sync for TokenAmount
impl Unpin for TokenAmount
impl UnwindSafe for TokenAmount
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)