pub fn into_assignment<P: PerThing>(self) -> Option<Assignment<AccountId, P>>
	where
		ExtendedBalance: From<InnerOf<P>>,
	{
		let who = self.who;
		let budget = self.budget;
		let distribution = self.edges.into_iter().filter_map(|e| {
			let per_thing = P::from_rational_approximation(e.weight, budget);
			// trim zero edges.
			if per_thing.is_zero() { None } else { Some((e.who, per_thing)) }
		}).collect::<Vec<_>>();

		if distribution.len() > 0 {
			Some(Assignment { who, distribution })
		} else {
			None
		}
	}
/// Returns none if this voter does not have any non-zero distributions.
///
/// Note that this might create _un-normalized_ assignments, due to accuracy loss of `P`. Call
/// site might compensate by calling `normalize()` on the returned `Assignment` as a
/// post-precessing.
Returns none if this voter does not have any non-zero distributions.
Note that this might create _un-normalized_ assignments, due to accuracy loss of `P`. Call
site might compensate by calling `normalize()` on the returned `Assignment` as a
post-precessing.
Returns none if this voter does not have any non - zero distributions . Note that this might create _un - normalized_ assignments due to accuracy loss of ` P ` . Call site might compensate by calling ` normalize () ` on the returned ` Assignment ` as a post - precessing .
pub fn into_assignment<P: PerThing>(self) -> Option<Assignment<AccountId, P>>
	where
		ExtendedBalance: From<InnerOf<P>>,
	{
		let who = self.who;
		let budget = self.budget;
		let distribution = self.edges.into_iter().filter_map(|e| {
			let per_thing = P::from_rational_approximation(e.weight, budget);
			// trim zero edges.
			if per_thing.is_zero() { None } else { Some((e.who, per_thing)) }
		}).collect::<Vec<_>>();
		if distribution.len() > 0 {
			Some(Assignment { who, distribution })
		} else {
			None
		}
	}
pub fn into_assignment < P : PerThing > ( self ) -> Option < Assignment < AccountId , P > > where ExtendedBalance : From < InnerOf < P > > , { let who = self . who ; let budget = self . budget ; let distribution = self . edges . into_iter ( ) . filter_map ( | e | { let per_thing = P :: from_rational_approximation ( e . weight , budget ) ; // trim zero edges. if per_thing . is_zero ( ) { None } else { Some ( ( e . who , per_thing ) ) } } ) . collect :: < Vec < _ > > ( ) ; if distribution . len ( ) > 0 { Some ( Assignment { who , distribution } ) } else { None } }
Returns none if this voter does not have any non-zero distributions.
Returns none if this voter does not have any non - zero distributions .
self
self