Closed
Description
I have to use some sort of loop construct within a const function. rustc --explain E0744
does explain that loop constructs are at the moment not supported, but as I was trying out for
first and the compiler rejected it, it would have been helpful if the explanation would hint me towards while
working.
I think the doc just needs a small update and I think the file to update is https://github.com/rust-lang/rust/blob/master/compiler/rustc_error_codes/src/error_codes/E0744.md
I tried this code:
const fn foo() -> [u8; 10] {
let mut a = [0; 10];
let b = b"hi";
let mut i = 0;
while i < b.len() {
a[i] = b[i];
i += 1;
}
a
}
pub const BAR: [u8; 10] = foo();
Meta
rustc --version --verbose
:
rustc 1.47.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.47.0
LLVM version: 11.0