Skip to content

chrono 0.5 Duration #59

@fsktom

Description

@fsktom

See chronotope/chrono#1137

When they do this, I'll have to probably rename chrono::Duration to whatever they decide on (currently TimeDelta), but I'll finally be able to use += (no longer necessary tbh), but they implement iter::Sum !!!

https://github.com/chronotope/chrono/blob/f5ea3ec216d8c34cd0346bc8b105287f9f641d2e/src/time_delta.rs#L392-L406

I won't have to use .fold(...) xd but a more concise .sum() instead :D
e.g. here

pub fn listening_time(entries: &[SongEntry]) -> Duration {
// sadly doesn't work bc neither chrono::Duration nor std::time::Duration implement iter::sum :))))
// self.iter().map(|entry| entry.time_played).sum::<Duration>()
entries
.iter()
.map(|entry| entry.time_played)
.fold(Duration::milliseconds(0), |sum, dur| sum + dur)
}

Metadata

Metadata

Assignees

Labels

cliRegarding `endsong_ui` cratedependencyWaiting for a change in a dependencylibraryRegarding `endsong` craterefactor

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions