improve sum_as_str

This commit is contained in:
kageru 2020-04-19 19:07:54 +02:00
parent 84f13d1806
commit 1be551d4f5
Signed by untrusted user: kageru
GPG Key ID: 8282A2BEA4ADA3D2

View File

@ -94,10 +94,10 @@ impl TimeSheet {
pub fn sum_as_str(&self) -> String {
let total = self
.times
.windows(2)
.fold(time::Duration::zero(), |total, ts| {
let last = ts[0].time;
let next = ts[1].time;
.iter()
.map(|tp| tp.time)
.tuple_windows()
.fold(time::Duration::zero(), |total, (last, next)| {
total + (next - last)
});
format_duration(&total)