Trait UnsafeConstructorDestructor
pub trait UnsafeConstructorDestructor<Balance> {
// Required methods
fn unsafe_clone(&self) -> Box<dyn ImbalanceAccounting<Balance>>;
fn forget_imbalance(&mut self) -> Balance;
}Expand description
Unsafe imbalance cloning constructor and forgetful destructor.
This trait provides low-level operations that can violate imbalance invariants if misused. These methods are separated into their own trait to make it explicit when unsafe operations are being performed.
Required Methods§
fn unsafe_clone(&self) -> Box<dyn ImbalanceAccounting<Balance>>
fn unsafe_clone(&self) -> Box<dyn ImbalanceAccounting<Balance>>
Duplicates/clones the imbalance type, effectively leading to double accounting of the imbalance.
Warning: Use with care!!! one of the duplicates should call self.forget_amount() for the
double-tracking to be removed.
fn forget_imbalance(&mut self) -> Balance
fn forget_imbalance(&mut self) -> Balance
Forgets about the inner imbalance. Drops the inner imbalance without actually resolving it.
Usually implemented by simply setting the imbalance amount to zero.
Note this is not equivalent mem::forget() as the destructor is still called, and memory is
freed, but imbalance amount to resolve is zero/noop.
Returns the amount “forgotten”.