Skip to content

Commit

Permalink
Add a Sum implementation for Au (#55)
Browse files Browse the repository at this point in the history
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()`.
  • Loading branch information
mrobinson authored Feb 1, 2024
1 parent a5bf3ba commit 190ea4f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "app_units"
version = "0.7.4"
version = "0.7.5"
authors = ["The Servo Project Developers"]
description = "Servo app units type (Au)"
documentation = "https://docs.rs/app_units/"
Expand Down
6 changes: 6 additions & 0 deletions src/app_unit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,12 @@ impl<'a> Sum<&'a Self> for Au {
}
}

impl<'a> Sum<Self> for Au {
fn sum<I: Iterator<Item = Self>>(iter: I) -> Self {
iter.fold(Self::zero(), |a, b| a + b)
}
}

impl Au {
/// FIXME(pcwalton): Workaround for lack of cross crate inlining of newtype structs!
#[inline]
Expand Down

0 comments on commit 190ea4f

Please sign in to comment.