Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Implement `Ord` and `Eq` for unit types

Open
#717 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
backend

Research direction

Start with the discussion quoted from issue #707, then inspect the unit-type definitions and existing tests in the repository. Clarify whether the scope is limited to implementing Ord and Eq or also includes NaN handling, Option-based values, and constructors. Done means an agreed scope and corresponding trait behavior, but no files or tests are named here.

Written by the indexing model from the issue text.

Description

question

Thanks for explaining. It's probably fine as it is then, but if ordered_float is easy to implement then it might be nice.

I'll take another look tomorrow to see how faffy it is. Maybe it should be a separate PR.

Worth thinking about nans though. I don't imagine we'll ever want unit types to be nan, but there are certainly times where these could crop up and we'll need to deal with them. I wonder if NotNan could be something to consider. This will panic if nans are ever encountered, which will force us to explicitly deal with these scenarios (e.g. adding an epsilon to prevent a 0/0 division)

Yeah, I don't think so either. I think it would be a bit more Rusty to have an Option<Activity> rather than an Activity that might be NaN. I've grepped the code base and it looks like the only NaN unit types that exist are in tests, so it might be safe to swap over.

My only worry is that there could be performance implications to the extra checks that would be implicitly needed for all kinds of floating point operations, but maybe that's not worth worrying about.

The other thing is that we would need to create unit types with a constructor, because writing e.g. Activity(1.0) wouldn't work anymore.

Originally posted by @alexdewar in https://github.com/EnergySystemsModellingLab/MUSE_2.0/issues/707#issuecomment-3103737555

Dominant language
Rust
Stars
8
Forks
5
Avg merge
11h 31m
Merged PRs (30d)
33

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from EnergySystemsModellingLab/MUSE2

All issues in EnergySystemsModellingLab/MUSE2

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.