Fix link: The const_fn unstable feature no longer exists

There is now a description of `const` functions in the Rust reference, so we can link there instead.
This commit is contained in:
Philipp Oppermann
2021-08-07 10:25:17 +02:00
parent d8eff6ba3e
commit c1e6a66e35
4 changed files with 4 additions and 4 deletions

View File

@@ -484,7 +484,7 @@ To understand what's happening here, we need to know that statics are initialize
The issue about `ColorCode::new` would be solvable by using [`const` functions], but the fundamental problem here is that Rust's const evaluator is not able to convert raw pointers to references at compile time. Maybe it will work someday, but until then, we have to find another solution.
[`const` functions]: https://doc.rust-lang.org/unstable-book/language-features/const-fn.html
[`const` functions]: https://doc.rust-lang.org/reference/const_eval.html#const-functions
### Lazy Statics
The one-time initialization of statics with non-const functions is a common problem in Rust. Fortunately, there already exists a good solution in a crate named [lazy_static]. This crate provides a `lazy_static!` macro that defines a lazily initialized `static`. Instead of computing its value at compile time, the `static` laziliy initializes itself when it's accessed the first time. Thus, the initialization happens at runtime so that arbitrarily complex initialization code is possible.