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

Add time constants #216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add time constants #216

wants to merge 1 commit into from

Conversation

Ben-PH
Copy link

@Ben-PH Ben-PH commented Dec 6, 2024

I have Use cases where having direct access to U3600 is needed. I tried making a type U3600 = op!(U36 * 100);, but when I try implementing for something that looks like this, I get an error:

trait SpecializedPeriod {}
impl SpecializedPeriod for Period<op!(U36 * U100), U1> {}
impl SpecializedPeriod for Period<U60, U1> {}
impl SpecializedPeriod for Period<U1, U1> {}
error[E0119]: conflicting implementations of trait `SpecializedPeriod` for type `period::Period<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>, B0>, B0>, UInt<UTerm, B1>>`
  --> src/duration/period.rs:15:1
   |
14 | impl SpecializedPeriod for Period<op!(U36 * U100), U1> {}
   | ------------------------------------------------------ first implementation here
15 | impl SpecializedPeriod for Period<U60, U1> {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `period::Period<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B1>, B1>, B0>, B0>, UInt<UTerm, B1>>`

error[E0119]: conflicting implementations of trait `SpecializedPeriod` for type `period::Period<UInt<UTerm, B1>, UInt<UTerm, B1>>`
  --> src/duration/period.rs:16:1
   |
14 | impl SpecializedPeriod for Period<op!(U36 * U100), U1> {}
   | ------------------------------------------------------ first implementation here
15 | impl SpecializedPeriod for Period<U60, U1> {}
16 | impl SpecializedPeriod for Period<U1, U1> {}
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `period::Period<UInt<UTerm, B1>, UInt<UTerm, B1>>`

This allows for such numbers to be used directly.

A follow-up issue might be to setup some way to provide specific numbers in a config file if needed, and provide these vals to the build script somehow, but that's well out of scope for this PR.

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

Successfully merging this pull request may close these issues.

1 participant