-
Notifications
You must be signed in to change notification settings - Fork 97
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
Add zero constants/methods for each quantity #26
Comments
|
Since the const UNIX_EPOCH_DELTA: Time = Time::new::<time::second>(11644473600.0); EDIT: I'm starting to think that this was a wrong issue to add this comment :) Do you want me to create a new issue? |
#165 added! It's not pretty, but you can define constants right now as follows: const UNIX_EPOCH_DELTA: Time = Time { dimension: PhantomData, units: PhantomData, value: 11644473600.0, }; |
What about adding something like impl<D, U> Quantity<D, U> {
pub const fn new_in_base_units(value: U) -> Self {
dimension: PhantomData,
units: PhantomData,
value,
}
} That way we'd be able to write It's not ideal, but at least it gives people a way to create |
That's an excellent idea. If someone wants to submit a PR add the new method just below Lines 292 to 307 in 409252e
|
I don't think it's possible with the way
Placing Because the struct definition contains a where clause, any function creating a
I know the Rust API guidelines recommend not putting where clauses on a generic struct's declaration and only placing it on impl blocks, but to change that now would be a breaking change and a making a new major release for a single |
So my few days apparently turned into 20 days. I haven't forgotten about this and it's still on my to-do list. I just haven't made time to get to it yet. |
Whats the status of this issue? |
Still starred in my inbox waiting for me to get to it unfortunately. I'm trying to get #229 merged. That in turn is blocked while I'm trying to update dependencies which uncovered some floating point precision issues. |
Add
constant
? Addconst fn
?impl Zero
?The text was updated successfully, but these errors were encountered: