aboutsummaryrefslogtreecommitdiff
path: root/embassy-time
diff options
context:
space:
mode:
authorMatt Johnston <[email protected]>2025-08-16 22:40:04 +0800
committerMatt Johnston <[email protected]>2025-08-17 22:21:13 +0800
commit1b246d77c9972706285193b7a17ae0f5543e5a34 (patch)
tree3a51ddc6f6eaca4ab82d18cf62353d517f1b8de7 /embassy-time
parentbfe4395b3b9792bb79363e2f32a9ab7bf69bb78d (diff)
time: implement Sum for Duration
Diffstat (limited to 'embassy-time')
-rw-r--r--embassy-time/CHANGELOG.md1
-rw-r--r--embassy-time/src/duration.rs9
2 files changed, 10 insertions, 0 deletions
diff --git a/embassy-time/CHANGELOG.md b/embassy-time/CHANGELOG.md
index a0c1abe8d..2e94e0112 100644
--- a/embassy-time/CHANGELOG.md
+++ b/embassy-time/CHANGELOG.md
@@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15- Don't select `critical-section` impl for `std` 15- Don't select `critical-section` impl for `std`
16- Manually implement the future for `with_timeout` 16- Manually implement the future for `with_timeout`
17- Add 133MHz tick rate to support PR2040 @ 133MHz when `TIMERx`'s `SOURCE` is set to `SYSCLK` 17- Add 133MHz tick rate to support PR2040 @ 133MHz when `TIMERx`'s `SOURCE` is set to `SYSCLK`
18- Implement Sum for Duration
18 19
19## 0.4.0 - 2025-01-02 20## 0.4.0 - 2025-01-02
20 21
diff --git a/embassy-time/src/duration.rs b/embassy-time/src/duration.rs
index dcda705d3..5b140eeff 100644
--- a/embassy-time/src/duration.rs
+++ b/embassy-time/src/duration.rs
@@ -293,3 +293,12 @@ impl From<Duration> for core::time::Duration {
293 core::time::Duration::from_micros(value.as_micros()) 293 core::time::Duration::from_micros(value.as_micros())
294 } 294 }
295} 295}
296
297impl core::iter::Sum for Duration {
298 fn sum<I>(iter: I) -> Self
299 where
300 I: Iterator<Item = Duration>,
301 {
302 Duration::from_ticks(iter.map(|d| d.as_ticks()).sum())
303 }
304}