Comments (4)
Are there any difficulties or pitfalls here, or is it just a fairly mechanical process that simply requires finding the time to do it?
If it's the latter, I'll start chipping away at it.
If it's the former, I could also have a go, if you brief me.
from uom.
Should be completely mechanical.
Implementation would start with the following macros
Lines 588 to 591 in 66d3e85
And you can compare against what the standard library is doing for inspiration on implementing for T
and &T
. https://doc.rust-lang.org/src/core/ops/arith.rs.html#117-133
Once the major traits are implemented we can go hunting to see if there is anything else like Sub
that needs extra impls.
from uom.
Implementation would start with the following macros [
impl_ops!
]
Just to be sure: Are you suggesting to add the implementations of the reference versions, to the bodies of those macros?
I don't quite understand the pattern inside the macro. First we have this group of 4:
....autoconvert! ... AddSubTrait
not_autoconvert! ... AddSubTrait
....autoconvert! ... AddSubAssignTrait
not_autoconvert! ... AddSubAssignTrait
followed by another group of 4:
....autoconvert! ... MulDivTrait
not_autoconvert! ... MulDivTrait
................ ... MulDivTrait
................ ... MulDivAssignTrait
Why is there an asymmetry between the AddSub
group and the MulDiv
group?
from uom.
I apologize for taking so long to get to this. I'll look at the PR in a second to see what you've done so far. The original thought was to do something to the standard library and use a macro that accepts the type (T
vs. &T
) as a parameter.
The asymmetry is because multiply and divide allow for operating on the underlying storage type as well as the quantity. e.g. length * time
and length * 3.0
. Add/subtract require the same quantity on both sides of the operator. e.g. length1 + length2
. The [not_]autoconvert!
macros decide if the implementation supports operating on quantities with different base units.
from uom.
Related Issues (20)
- Implement operations on Dimension
- Suggestion: pass units as values HOT 2
- Suggestion: allow multiplying by a unit HOT 2
- Add Dimension type to Unit trait HOT 4
- Understand reason of 'attempt to divide by zero' HOT 2
- ElectricalPotential and Current not working with ISQ! base unit change HOT 1
- [Bug] test failure on debian HOT 5
- Change base unit of Unit not defined in the SI Quantities System but listed as SI Unit HOT 2
- Enthalpy and Entropy HOT 2
- Implement clamp HOT 2
- Unit for moving mass over distance
- Is a "Cycle" (or something similar) quantity reasonable? HOT 2
- Subtracting thermodynamic temperatures should produce a temperature interval HOT 5
- Suggestion: Using const generics to express quantities info HOT 9
- error[E0277]: the trait bound `<<D as si::Dimension>::L as std::ops::Neg>::Output: Integer` is not satisfied HOT 2
- Request: FrequencyShift HOT 2
- Support defmt framework HOT 2
- Bump MSRV HOT 3
- Support new SI prefixes
- How to use a base unit that's not predefined? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uom.