-
Notifications
You must be signed in to change notification settings - Fork 13.3k
It is not possible to assign a Duration to a const variable #18166
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
Comments
There's a legit |
Can this wait for Compile Time Function Evaluation to be implemented properly? It seems like that would be the correct solution to this problem (unless having the fields public is otherwise desirable). |
This commit changes the internal representation of Duration from pub struct Duraion { secs: i64, nanos: i32 } to /// An absolute amount of time, independent of time zones /// and calendars with tick precision. A single tick /// represents 100 nanoseconds. pub struct Duration(pub i64) Closes rust-lang#18166,rust-lang#18416.
This is still true today. |
Sample program:
This is basically always going to be true until |
…Veykril fix: Fix a bug in span map merge, and add explanations of how span maps are stored Because it took me hours to figure out that contrary to common sense, the offset stored is the *end* of the node, and we search by the *start*. Which is why we need a convoluted `partition_point()` instead of a simple `binary_search()`. And this was not documented at all. Which made me make mistakes with my implementation of `SpanMap::merge()`. The other bug fixed about span map merging is correctly keeping track of the current offset in presence of multiple sibling macro invocations. Unrelated, but because of the previous issue it took me hours to debug, so I figured out I'll put them together for posterity. Fixes rust-lang#18163.
The struct fields are currently not pub making it impossible to assign Duration to a const variable.
Given that Duration is essentially
timespec
, it seems like it might be a good idea to make the struct fields public.cc @aturon
The text was updated successfully, but these errors were encountered: