Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement PartialOrd for Month #998

Closed
Munksgaard opened this issue Mar 24, 2023 · 3 comments
Closed

Implement PartialOrd for Month #998

Munksgaard opened this issue Mar 24, 2023 · 3 comments

Comments

@Munksgaard
Copy link
Contributor

Munksgaard commented Mar 24, 2023

It would be nice if Month implemented PartialOrd.

For instance, I have a situation where I am aggregating data on a monthly basis, year by year. For that, I have a YearMonth struct like this:

struct YearMonth {
    year: i32,
    month: Month,
}

For the actual calculation, this is then used as key in a HashMap, or part of a tuple inside a Vec. I then want to find all the YearMonth for the last 12 months, which means I have a comparison like .filter(|year_month| year_month >= current_year_month.month.minus_one_year()) . Since Month does not implement PartialOrd, I cannot simply derive the implementation for YearMonth, but have to implement my own.

@djc
Copy link
Contributor

djc commented Mar 24, 2023

Makes sense, would you be able to submit a PR?

@Munksgaard
Copy link
Contributor Author

Makes sense, would you be able to submit a PR?

Yes, I can do that.

@Munksgaard
Copy link
Contributor Author

Closed by #999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants