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

const fn constructors #111

Closed
faern opened this issue Dec 10, 2019 · 1 comment · Fixed by #137
Closed

const fn constructors #111

faern opened this issue Dec 10, 2019 · 1 comment · Fixed by #137

Comments

@faern
Copy link
Contributor

faern commented Dec 10, 2019

We can now/soon have const fn constructors thanks to if statements now working in const on nightly: https://blog.rust-lang.org/inside-rust/2019/11/25/const-if-match.html

We could implement it now already with a nightly feature and duplicate all constructors and conditionally compile them with #[cfg(feature = "nightly")]. But unless there is significant demand we could just wait and hope it reaches stable in a few versions.

This would improve the usability of this crate a lot. One of the most common ways I define IP networks in my code is global constants, which I currently have to use lazy_static! or similar to achieve.

@faern
Copy link
Contributor Author

faern commented Apr 29, 2020

Adding the link to the tracking issue for if in const fns here. For reference.
rust-lang/rust#49146

achanda added a commit that referenced this issue Aug 27, 2020
IpNetwork::new cannot be const since it is not supported with the ?
operator

Closes #111
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 a pull request may close this issue.

1 participant