mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-07-20 11:35:41 +00:00
Remove manual implementation (#14096)
This commit is contained in:
@@ -22,9 +22,10 @@ use crate::{
|
|||||||
Perbill,
|
Perbill,
|
||||||
};
|
};
|
||||||
use core::ops::Sub;
|
use core::ops::Sub;
|
||||||
|
use scale_info::TypeInfo;
|
||||||
|
|
||||||
/// Piecewise Linear function in [0, 1] -> [0, 1].
|
/// Piecewise Linear function in [0, 1] -> [0, 1].
|
||||||
#[derive(PartialEq, Eq, sp_core::RuntimeDebug)]
|
#[derive(PartialEq, Eq, sp_core::RuntimeDebug, TypeInfo)]
|
||||||
pub struct PiecewiseLinear<'a> {
|
pub struct PiecewiseLinear<'a> {
|
||||||
/// Array of points. Must be in order from the lowest abscissas to the highest.
|
/// Array of points. Must be in order from the lowest abscissas to the highest.
|
||||||
pub points: &'a [(Perbill, Perbill)],
|
pub points: &'a [(Perbill, Perbill)],
|
||||||
@@ -32,36 +33,6 @@ pub struct PiecewiseLinear<'a> {
|
|||||||
pub maximum: Perbill,
|
pub maximum: Perbill,
|
||||||
}
|
}
|
||||||
|
|
||||||
// This can be replaced with
|
|
||||||
// #[derive(scale_info::TypeInfo)]
|
|
||||||
// #[scale_info(skip_type_params(S))]
|
|
||||||
// again once this issue is fixed in the rust compiler: https://github.com/rust-lang/rust/issues/96956
|
|
||||||
// Tracking issues: https://github.com/paritytech/substrate/issues/11915
|
|
||||||
impl scale_info::TypeInfo for PiecewiseLinear<'static> {
|
|
||||||
type Identity = Self;
|
|
||||||
fn type_info() -> ::scale_info::Type {
|
|
||||||
scale_info::Type::builder()
|
|
||||||
.path(scale_info::Path::new("PiecewiseLinear", "sp_runtime::curve"))
|
|
||||||
.type_params(crate::Vec::new())
|
|
||||||
.docs(&["Piecewise Linear function in [0, 1] -> [0, 1]."])
|
|
||||||
.composite(
|
|
||||||
scale_info::build::Fields::named()
|
|
||||||
.field(|f| {
|
|
||||||
f.ty::<&'static[(Perbill, Perbill)]>()
|
|
||||||
.name("points")
|
|
||||||
.type_name("&'static[(Perbill, Perbill)]")
|
|
||||||
.docs(&["Array of points. Must be in order from the lowest abscissas to the highest."])
|
|
||||||
})
|
|
||||||
.field(|f| {
|
|
||||||
f.ty::<Perbill>()
|
|
||||||
.name("maximum")
|
|
||||||
.type_name("Perbill")
|
|
||||||
.docs(&["The maximum value that can be returned."])
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn abs_sub<N: Ord + Sub<Output = N> + Clone>(a: N, b: N) -> N where {
|
fn abs_sub<N: Ord + Sub<Output = N> + Clone>(a: N, b: N) -> N where {
|
||||||
a.clone().max(b.clone()) - a.min(b)
|
a.clone().max(b.clone()) - a.min(b)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user