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

Make functions const where possible #165

Open
iliekturtles opened this issue Sep 4, 2019 · 3 comments
Open

Make functions const where possible #165

iliekturtles opened this issue Sep 4, 2019 · 3 comments

Comments

@iliekturtles
Copy link
Owner

Requires Rust 1.31 for support. Bump requirement for v1.0 or continuing to wait on feature until v2.0? What methods can be const besides new. Will const fn make zero constants easier (#26)?

@Maher4Ever
Copy link

Is there an update on this issue? It would great to allow defining quantities in a const variable as shown in #26:

const UNIX_EPOCH_DELTA: Time = Time::new::<time::second>(11644473600.0);

@iliekturtles
Copy link
Owner Author

No updates yet. I just haven't had/made the time to get to it. PRs very welcome if anyone wants to tackle this. I would probably start by dropping a const in front of everything and then seeing what sticks.

@adamreichold
Copy link
Contributor

I would probably start by dropping a const in front of everything and then seeing what sticks.

I am not sure this is currently possible for all storage types, e.g. for floating-point numbers the conversion to the system's base unit generally involves floating-point arithmetic which is still unstable behind the feature const_fn_floating_point_arithmetic. This would again leave us with #26 (comment) to create constant quantities.

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