Skip to content

Commit 190ea4f

Browse files
authored
Add a Sum implementation for Au (#55)
My previous change only added an implementation of sum for `&Au`, but this isn't always good enough when you are dealing with `into_iter()`.
1 parent a5bf3ba commit 190ea4f

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "app_units"
3-
version = "0.7.4"
3+
version = "0.7.5"
44
authors = ["The Servo Project Developers"]
55
description = "Servo app units type (Au)"
66
documentation = "https://docs.rs/app_units/"

src/app_unit.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,12 @@ impl<'a> Sum<&'a Self> for Au {
187187
}
188188
}
189189

190+
impl<'a> Sum<Self> for Au {
191+
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
192+
iter.fold(Self::zero(), |a, b| a + b)
193+
}
194+
}
195+
190196
impl Au {
191197
/// FIXME(pcwalton): Workaround for lack of cross crate inlining of newtype structs!
192198
#[inline]

0 commit comments

Comments
 (0)