mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-30 03:31:05 +00:00
extract amount method for fungible/s Imbalance (#1847)
Introduces an `extract` amount method for `fungible/s` `Imbalance`.
This commit is contained in:
@@ -100,6 +100,11 @@ mod imbalances {
|
||||
mem::forget(self);
|
||||
(Self(first), Self(second))
|
||||
}
|
||||
fn extract(&mut self, amount: T::Balance) -> Self {
|
||||
let new = self.0.min(amount);
|
||||
self.0 = self.0 - new;
|
||||
Self(new)
|
||||
}
|
||||
fn merge(mut self, other: Self) -> Self {
|
||||
self.0 = self.0.saturating_add(other.0);
|
||||
mem::forget(other);
|
||||
@@ -159,6 +164,11 @@ mod imbalances {
|
||||
mem::forget(self);
|
||||
(Self(first), Self(second))
|
||||
}
|
||||
fn extract(&mut self, amount: T::Balance) -> Self {
|
||||
let new = self.0.min(amount);
|
||||
self.0 = self.0 - new;
|
||||
Self(new)
|
||||
}
|
||||
fn merge(mut self, other: Self) -> Self {
|
||||
self.0 = self.0.saturating_add(other.0);
|
||||
mem::forget(other);
|
||||
|
||||
Reference in New Issue
Block a user