Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/std/src/math/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,10 +361,10 @@ impl ops::DivAssign<Uint128> for Decimal {

impl<A> std::iter::Sum<A> for Decimal
where
Decimal: ops::Add<A, Output = Decimal>,
Self: ops::Add<A, Output = Self>,
{
fn sum<I: Iterator<Item = A>>(iter: I) -> Self {
iter.fold(Self::zero(), |a, b| a + b)
iter.fold(Self::zero(), ops::Add::add)
}
}

Expand Down
4 changes: 2 additions & 2 deletions packages/std/src/math/decimal256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ impl ops::DivAssign<Uint256> for Decimal256 {

impl<A> std::iter::Sum<A> for Decimal256
where
Decimal256: ops::Add<A, Output = Decimal256>,
Self: ops::Add<A, Output = Self>,
{
fn sum<I: Iterator<Item = A>>(iter: I) -> Self {
iter.fold(Self::zero(), |a, b| a + b)
iter.fold(Self::zero(), ops::Add::add)
}
}

Expand Down
16 changes: 6 additions & 10 deletions packages/std/src/math/uint128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use schemars::JsonSchema;
use serde::{de, ser, Deserialize, Deserializer, Serialize};
use std::convert::{TryFrom, TryInto};
use std::fmt::{self};
use std::iter::Sum;
use std::ops;
use std::str::FromStr;

Expand Down Expand Up @@ -471,15 +470,12 @@ impl<'de> de::Visitor<'de> for Uint128Visitor {
}
}

impl Sum<Uint128> for Uint128 {
fn sum<I: Iterator<Item = Uint128>>(iter: I) -> Self {
iter.fold(Uint128::zero(), ops::Add::add)
}
}

impl<'a> Sum<&'a Uint128> for Uint128 {
fn sum<I: Iterator<Item = &'a Uint128>>(iter: I) -> Self {
iter.fold(Uint128::zero(), ops::Add::add)
impl<A> std::iter::Sum<A> for Uint128
where
Self: ops::Add<A, Output = Self>,
{
fn sum<I: Iterator<Item = A>>(iter: I) -> Self {
iter.fold(Self::zero(), ops::Add::add)
}
}

Expand Down
16 changes: 6 additions & 10 deletions packages/std/src/math/uint256.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use schemars::JsonSchema;
use serde::{de, ser, Deserialize, Deserializer, Serialize};
use std::convert::{TryFrom, TryInto};
use std::fmt;
use std::iter::Sum;
use std::ops::{self, Shl, Shr};
use std::str::FromStr;

Expand Down Expand Up @@ -632,15 +631,12 @@ impl<'de> de::Visitor<'de> for Uint256Visitor {
}
}

impl Sum<Uint256> for Uint256 {
fn sum<I: Iterator<Item = Uint256>>(iter: I) -> Self {
iter.fold(Uint256::zero(), ops::Add::add)
}
}

impl<'a> Sum<&'a Uint256> for Uint256 {
fn sum<I: Iterator<Item = &'a Uint256>>(iter: I) -> Self {
iter.fold(Uint256::zero(), ops::Add::add)
impl<A> std::iter::Sum<A> for Uint256
where
Self: ops::Add<A, Output = Self>,
{
fn sum<I: Iterator<Item = A>>(iter: I) -> Self {
iter.fold(Self::zero(), ops::Add::add)
}
}

Expand Down
16 changes: 6 additions & 10 deletions packages/std/src/math/uint512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use schemars::JsonSchema;
use serde::{de, ser, Deserialize, Deserializer, Serialize};
use std::convert::{TryFrom, TryInto};
use std::fmt;
use std::iter::Sum;
use std::ops::{self, Shr};
use std::str::FromStr;

Expand Down Expand Up @@ -659,15 +658,12 @@ impl<'de> de::Visitor<'de> for Uint512Visitor {
}
}

impl Sum<Uint512> for Uint512 {
fn sum<I: Iterator<Item = Uint512>>(iter: I) -> Self {
iter.fold(Uint512::zero(), ops::Add::add)
}
}

impl<'a> Sum<&'a Uint512> for Uint512 {
fn sum<I: Iterator<Item = &'a Uint512>>(iter: I) -> Self {
iter.fold(Uint512::zero(), ops::Add::add)
impl<A> std::iter::Sum<A> for Uint512
where
Self: ops::Add<A, Output = Self>,
{
fn sum<I: Iterator<Item = A>>(iter: I) -> Self {
iter.fold(Self::zero(), ops::Add::add)
}
}

Expand Down
16 changes: 6 additions & 10 deletions packages/std/src/math/uint64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use schemars::JsonSchema;
use serde::{de, ser, Deserialize, Deserializer, Serialize};
use std::convert::{TryFrom, TryInto};
use std::fmt::{self};
use std::iter::Sum;
use std::ops;

use crate::errors::{DivideByZeroError, OverflowError, OverflowOperation, StdError};
Expand Down Expand Up @@ -355,15 +354,12 @@ impl<'de> de::Visitor<'de> for Uint64Visitor {
}
}

impl Sum<Uint64> for Uint64 {
fn sum<I: Iterator<Item = Uint64>>(iter: I) -> Self {
iter.fold(Uint64::zero(), ops::Add::add)
}
}

impl<'a> Sum<&'a Uint64> for Uint64 {
fn sum<I: Iterator<Item = &'a Uint64>>(iter: I) -> Self {
iter.fold(Uint64::zero(), ops::Add::add)
impl<A> std::iter::Sum<A> for Uint64
where
Self: ops::Add<A, Output = Self>,
{
fn sum<I: Iterator<Item = A>>(iter: I) -> Self {
iter.fold(Self::zero(), ops::Add::add)
}
}

Expand Down