Hello, I've been trying to create a static array which contains reference to value in another static array. Even though code below should type-check in my opinion. It does not compile. Looking at MIR problem seems to be with operator which generates Len((*(a: &'static [&'static [i8]])));
for boundaries checking.
Questions:
- Do I have mistake in my reasoning?
- What are alternatives
static a: &[&[i8]] = &[&[1]];
static b: &[&[i8]] = &[a[0]];
fn main() {
}
Errors:
Compiling playground v0.0.1 (file:///playground)
error[E0394]: cannot refer to other statics by value, use the address-of operator or a constant instead
--> src/main.rs:8:26
|
8 | static b: &[&&[i8]] = &[&a[0]];
| ^^^^ referring to another static by value
|
= note: use the address-of operator or a constant instead
error[E0394]: cannot refer to other statics by value, use the address-of operator or a constant instead
--> src/main.rs:8:25
|
8 | static b: &[&&[i8]] = &[&a[0]];
| ^^^^^ referring to another static by value
|
= note: use the address-of operator or a constant instead
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0394`.
error: Could not compile `playground`.
To learn more, run the command again with --verbose.