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

Allow subtracting two thermodynamic temperatures #447

Closed
ISibboI opened this issue Dec 5, 2023 · 3 comments
Closed

Allow subtracting two thermodynamic temperatures #447

ISibboI opened this issue Dec 5, 2023 · 3 comments

Comments

@ISibboI
Copy link
Contributor

ISibboI commented Dec 5, 2023

Hi, thanks for making uom! It has caught a few errors already in my small hobby project.

Currently, when I subtract two thermodynamic temperatures, I get the following error:

error[E0308]: mismatched types
   --> src\substance\water.rs:122:57
    |
122 |         let temperature_difference = self.temperature - target_temperature;
    |                                                         ^^^^^^^^^^^^^^^^^^ expected trait `Kind`, found trait `TemperatureKind`
    |
    = note: expected struct `Quantity<dyn Dimension<I = Z0, J = Z0, Kind = dyn Kind, L = Z0, M = Z0, N = Z0, T = Z0, Th = ...>, ..., ...>`
               found struct `Quantity<dyn Dimension<I = Z0, J = Z0, Kind = ..., L = ..., M = ..., N = ..., T = ..., Th = ...>, ..., ...>`

However, I would expect this to work and the result to be a TemperatureInterval.

@ISibboI
Copy link
Contributor Author

ISibboI commented Dec 5, 2023

How about adding another type parameter to Quantity that specifies if it can be added/subbed with itself or not? Then the default add/sub impl can be made only for some default value of that type parameter, and ThermodynamicTemperature could get its own implementation by having another value for this type parameter.

@iliekturtles
Copy link
Owner

Closing as a duplicate of #380.

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

3 participants