Attempt to remove the where bounds in arithmetic. (#7933)

* Attempt to remove the where bounds.

* Fix further and further.

* Format better.

* Update primitives/npos-elections/src/lib.rs

* fix build

* remove unused
This commit is contained in:
Kian Paimani
2021-01-21 09:39:30 +00:00
committed by GitHub
parent 9031c35114
commit 0dd8cd6277
11 changed files with 125 additions and 139 deletions
+8 -11
View File
@@ -114,19 +114,16 @@ impl_normalize_for_numeric!(u8, u16, u32, u64, u128);
impl<P: PerThing> Normalizable<P> for Vec<P> {
fn normalize(&self, targeted_sum: P) -> Result<Vec<P>, &'static str> {
let inners = self
.iter()
.map(|p| p.clone().deconstruct().into())
.collect::<Vec<_>>();
let uppers =
self.iter().map(|p| <UpperOf<P>>::from(p.clone().deconstruct())).collect::<Vec<_>>();
let normalized = normalize(inners.as_ref(), targeted_sum.deconstruct().into())?;
let normalized =
normalize(uppers.as_ref(), <UpperOf<P>>::from(targeted_sum.deconstruct()))?;
Ok(
normalized
.into_iter()
.map(|i: UpperOf<P>| P::from_parts(i.saturated_into()))
.collect()
)
Ok(normalized
.into_iter()
.map(|i: UpperOf<P>| P::from_parts(i.saturated_into::<P::Inner>()))
.collect())
}
}