Files
gpx.studio/gpx-rs/engine/src/core/statistics/utils.rs
T

13 lines
287 B
Rust
Raw Normal View History

2026-09-30 19:19:23 +02:00
use std::ops::Add;
pub fn sum_options<T>(a: Option<T>, b: Option<T>) -> Option<T>
where
T: Add<Output = T>,
{
match (a, b) {
(Some(a), Some(b)) => Some(a + b),
(Some(a), None) => Some(a),
(None, Some(b)) => Some(b),
(None, None) => None,
}
}