how to create a const BitArray #209
Answered
by
LuckyTurtleDev
LuckyTurtleDev
asked this question in
Q&A
-
Creating a const BitArray, where every element has the same value using the const TRANSPARENT: BitArray<[usize; 1], LocalBits> = bitarr![0;6]; But if I try to generate one, witch does have a different entrys, I get an error, because the used function is not const? error[E0015]: cannot call non-const fn `bitvec::array::BitArray::new` in constants
--> example/simple/src/main.rs:12:54
|
12 | const TRANSPARENT: BitArray<[usize; 1], LocalBits> = bitarr![0,0,0,0,1,0];
| ^^^^^^^^^^^^^^^^^^^^
|
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
= note: this error originates in the macro `$crate::bitarr` which comes from the expansion of the macro `bitarr` (in Nightly builds, run with -Z macro-backtrace for more info)
For more information about this error, try `rustc --explain E0015`. So how can a create such an BitArray? |
Beta Was this translation helpful? Give feedback.
Answered by
LuckyTurtleDev
Jan 14, 2023
Replies: 1 comment 1 reply
-
I have found the solution: const TRANSPARENT: BitArray<[usize; 1], LocalBits> = bitarr![const 0,0,0,0,1,0]; I have add it to the provided examples; see #210 |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
LuckyTurtleDev
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have found the solution:
I have add it to the provided examples; see #210