mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-01 04:17:24 +00:00
subxt: Derive std::cmp traits for subxt payloads and addresses (#1429)
* subxt/tx: Derive std::cmp traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/runtime_api: Derive std::cmp traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/constants: Derive std::cmp traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/custom_values: Derive std::cmp traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/storage: Derive std::cmp traits Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Fix non_canonical_partial_ord_impl clippy introduced in 1.73 Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add comment wrt derivative issue that triggers clippy warning Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Update subxt/src/backend/mod.rs * Update subxt/src/constants/constant_address.rs --------- Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> Co-authored-by: Niklas Adolfsson <niklasadolfsson1@gmail.com>
This commit is contained in:
@@ -28,7 +28,13 @@ pub trait ConstantAddress {
|
||||
|
||||
/// This represents the address of a constant.
|
||||
#[derive(Derivative)]
|
||||
#[derivative(Clone(bound = ""), Debug(bound = ""))]
|
||||
#[derivative(
|
||||
Clone(bound = ""),
|
||||
Debug(bound = ""),
|
||||
Eq(bound = ""),
|
||||
Ord(bound = ""),
|
||||
PartialEq(bound = "")
|
||||
)]
|
||||
pub struct Address<ReturnTy> {
|
||||
pallet_name: Cow<'static, str>,
|
||||
constant_name: Cow<'static, str>,
|
||||
@@ -36,6 +42,13 @@ pub struct Address<ReturnTy> {
|
||||
_marker: std::marker::PhantomData<ReturnTy>,
|
||||
}
|
||||
|
||||
// Manual implementation to work around https://github.com/mcarton/rust-derivative/issues/115.
|
||||
impl<ReturnTy> PartialOrd for Address<ReturnTy> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
|
||||
Some(self.cmp(other))
|
||||
}
|
||||
}
|
||||
|
||||
/// The type of address typically used to return dynamic constant values.
|
||||
pub type DynamicAddress = Address<DecodedValueThunk>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user