move full explanation to after erroneous example

This commit is contained in:
Brandon H. Gomes 2021-08-04 15:49:00 -04:00
parent 2f85aa6590
commit dc5f6d2e48

View File

@ -1,5 +1,4 @@
Static and const variables can refer to other const variables. But a const
variable cannot refer to a thread-local static variable.
A compile-time const variable is referring to a thread-local static variable.
Erroneous code example:
@ -12,8 +11,10 @@ static X: usize = 12;
const Y: usize = 2 * X;
```
In this example, `Y` cannot refer to `X`. To fix this, the value can be
extracted as a const and then used:
Static and const variables can refer to other const variables but a const
variable cannot refer to a thread-local static variable. In this example,
`Y` cannot refer to `X`. To fix this, the value can be extracted as a const
and then used:
```
#![feature(thread_local)]