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
@@ -25,7 +25,7 @@ use crate::{
IdentifierT, ElectionResult, ExtendedBalance, setup_inputs, VoteWeight, Voter, CandidatePtr,
balance, PerThing128,
};
use sp_arithmetic::{PerThing, InnerOf, Rational128, traits::Bounded};
use sp_arithmetic::{PerThing, Rational128, traits::Bounded};
use sp_std::{prelude::*, rc::Rc};
/// Execute the phragmms method.
@@ -46,10 +46,7 @@ pub fn phragmms<AccountId: IdentifierT, P: PerThing128>(
initial_candidates: Vec<AccountId>,
initial_voters: Vec<(AccountId, VoteWeight, Vec<AccountId>)>,
balancing_config: Option<(usize, ExtendedBalance)>,
) -> Result<ElectionResult<AccountId, P>, &'static str>
where
ExtendedBalance: From<InnerOf<P>>,
{
) -> Result<ElectionResult<AccountId, P>, &'static str> {
let (candidates, mut voters) = setup_inputs(initial_candidates, initial_voters);
let mut winners = vec![];
@@ -89,7 +86,7 @@ where
pub(crate) fn calculate_max_score<AccountId: IdentifierT, P: PerThing>(
candidates: &[CandidatePtr<AccountId>],
voters: &[Voter<AccountId>],
) -> Option<CandidatePtr<AccountId>> where ExtendedBalance: From<InnerOf<P>> {
) -> Option<CandidatePtr<AccountId>> {
for c_ptr in candidates.iter() {
let mut candidate = c_ptr.borrow_mut();
if !candidate.elected {