mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 08:11:04 +00:00
frame-support: RuntimeDebug\Eq\PartialEq impls for Imbalance (#1717)
Derive `RuntimeDebug\Eq\PartialEq` but do not bound any generics. This achieved by using their equivalent no bound versions: `EqNoBound\PartialEqNoBound\RuntimeDebugNoBound`. Deriving with `Debug`, `Eq`, and `PartialEq` for the `Debt` and `Credit` type aliases of `Imbalance` is not feasible due to the `OnDrop` and `OppositeOnDrop` generic types lacking implementations of the same traits. This absence posed challenges in testing and any scenarios that demanded the traits implementations for the type.
This commit is contained in:
@@ -23,7 +23,8 @@ use crate::traits::{
|
||||
misc::{SameOrOther, TryDrop},
|
||||
tokens::Balance,
|
||||
};
|
||||
use sp_runtime::{traits::Zero, RuntimeDebug};
|
||||
use frame_support_procedural::{EqNoBound, PartialEqNoBound, RuntimeDebugNoBound};
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Handler for when an imbalance gets dropped. This could handle either a credit (negative) or
|
||||
@@ -43,7 +44,7 @@ impl<Balance> HandleImbalanceDrop<Balance> for () {
|
||||
///
|
||||
/// Importantly, it has a special `Drop` impl, and cannot be created outside of this module.
|
||||
#[must_use]
|
||||
#[derive(RuntimeDebug, Eq, PartialEq)]
|
||||
#[derive(EqNoBound, PartialEqNoBound, RuntimeDebugNoBound)]
|
||||
pub struct Imbalance<
|
||||
B: Balance,
|
||||
OnDrop: HandleImbalanceDrop<B>,
|
||||
|
||||
@@ -23,7 +23,8 @@ use crate::traits::{
|
||||
misc::{SameOrOther, TryDrop},
|
||||
tokens::{AssetId, Balance},
|
||||
};
|
||||
use sp_runtime::{traits::Zero, RuntimeDebug};
|
||||
use frame_support_procedural::{EqNoBound, PartialEqNoBound, RuntimeDebugNoBound};
|
||||
use sp_runtime::traits::Zero;
|
||||
use sp_std::marker::PhantomData;
|
||||
|
||||
/// Handler for when an imbalance gets dropped. This could handle either a credit (negative) or
|
||||
@@ -38,7 +39,7 @@ pub trait HandleImbalanceDrop<AssetId, Balance> {
|
||||
///
|
||||
/// Importantly, it has a special `Drop` impl, and cannot be created outside of this module.
|
||||
#[must_use]
|
||||
#[derive(RuntimeDebug, Eq, PartialEq)]
|
||||
#[derive(EqNoBound, PartialEqNoBound, RuntimeDebugNoBound)]
|
||||
pub struct Imbalance<
|
||||
A: AssetId,
|
||||
B: Balance,
|
||||
|
||||
Reference in New Issue
Block a user