feat: add comprehensive energy unit conversion module#1014
Merged
siriak merged 1 commit intoTheAlgorithms:masterfrom Feb 7, 2026
Merged
feat: add comprehensive energy unit conversion module#1014siriak merged 1 commit intoTheAlgorithms:masterfrom
siriak merged 1 commit intoTheAlgorithms:masterfrom
Conversation
Contributor
Author
|
@siriak, this is ready to be merged. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1014 +/- ##
==========================================
- Coverage 96.12% 95.98% -0.14%
==========================================
Files 380 381 +1
Lines 28250 28535 +285
==========================================
+ Hits 27154 27388 +234
- Misses 1096 1147 +51 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
siriak
approved these changes
Feb 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR adds a new
energyconversion module to the conversions library, enabling conversion between 70+ energy units across different measurement systems and scientific disciplines.Implementation
Design Decisions
to_joule()→joule_to_unit()for clarity and maintainabilityEnergyUnitenum matching the repository'stemperature.rspattern for compile-time safetyJoule | WattSecond | NewtonMeter) for cleaner codeSupported Units (70+ units)
SI Units (8)
Power-Time Units (6)
Mechanical Units (3)
Calorie Variants (6)
Electron Volt Units (3)
British Thermal Units (3)
Imperial Force-Distance Units (7)
Horsepower Units (2)
Metric Force Units (5)
Therm Units (3)
Specialized Units (7)
Atomic Units (2)
Testing
Test Coverage
Test Organization
All tests use the
approx_eq()helper for floating-point comparisons with appropriate tolerances, ensuring robust validation across the full range of energy scales from attojoules to gigatons.Verification
Code Quality
f64for all calculations with appropriate tolerance checks (EPSILON = 1e-10)temperature.rsmodule patternExamples
References
All conversion factors are based on authoritative sources:
Checklist
cargo clippypasses with zero warnings)cargo testshows 100% pass rate)temperature.rs)mod.rswith proper exports