diff options
| -rw-r--r-- | embassy-time/CHANGELOG.md | 1 | ||||
| -rw-r--r-- | embassy-time/src/duration.rs | 9 |
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 | |||
| 297 | impl 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 | } | ||
