Skip to content

Commit a2dda85

Browse files
skunertnathanwhit
authored andcommitted
Remove manual implementation (paritytech#14096)
1 parent 1a2cff4 commit a2dda85

File tree

1 file changed

+2
-31
lines changed

1 file changed

+2
-31
lines changed

primitives/runtime/src/curve.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,17 @@ use crate::{
2222
Perbill,
2323
};
2424
use core::ops::Sub;
25+
use scale_info::TypeInfo;
2526

2627
/// Piecewise Linear function in [0, 1] -> [0, 1].
27-
#[derive(PartialEq, Eq, sp_core::RuntimeDebug)]
28+
#[derive(PartialEq, Eq, sp_core::RuntimeDebug, TypeInfo)]
2829
pub struct PiecewiseLinear<'a> {
2930
/// Array of points. Must be in order from the lowest abscissas to the highest.
3031
pub points: &'a [(Perbill, Perbill)],
3132
/// The maximum value that can be returned.
3233
pub maximum: Perbill,
3334
}
3435

35-
// This can be replaced with
36-
// #[derive(scale_info::TypeInfo)]
37-
// #[scale_info(skip_type_params(S))]
38-
// again once this issue is fixed in the rust compiler: https://github.com/rust-lang/rust/issues/96956
39-
// Tracking issues: https://github.com/paritytech/substrate/issues/11915
40-
impl scale_info::TypeInfo for PiecewiseLinear<'static> {
41-
type Identity = Self;
42-
fn type_info() -> ::scale_info::Type {
43-
scale_info::Type::builder()
44-
.path(scale_info::Path::new("PiecewiseLinear", "sp_runtime::curve"))
45-
.type_params(crate::Vec::new())
46-
.docs(&["Piecewise Linear function in [0, 1] -> [0, 1]."])
47-
.composite(
48-
scale_info::build::Fields::named()
49-
.field(|f| {
50-
f.ty::<&'static[(Perbill, Perbill)]>()
51-
.name("points")
52-
.type_name("&'static[(Perbill, Perbill)]")
53-
.docs(&["Array of points. Must be in order from the lowest abscissas to the highest."])
54-
})
55-
.field(|f| {
56-
f.ty::<Perbill>()
57-
.name("maximum")
58-
.type_name("Perbill")
59-
.docs(&["The maximum value that can be returned."])
60-
}),
61-
)
62-
}
63-
}
64-
6536
fn abs_sub<N: Ord + Sub<Output = N> + Clone>(a: N, b: N) -> N where {
6637
a.clone().max(b.clone()) - a.min(b)
6738
}

0 commit comments

Comments
 (0)