SQ in silver chrome letters, a lab's gear stacked against the S: a rack, two oscilloscopes, pizza boxes and a six-pack. Strange Query Lab

CARDIAC › rust-cardiac › Message codes › RCE0025

RCE0025error

A resource loaded outside main, or in a loop.

error[RCE0025]: load_resource("{name}") is only allowed in main, where it runs once: load it there and pass the array on
error[RCE0025]: load_resource("{name}") is in a loop: the loader fills it once, so load it before the loop

load_resource called where it can run more than once: in a function other than main, or in a loop.

A resource is filled once, by the loader, before the program starts. Natively, load_resource reads the file each time it is called; on CARDIAC there is no second reading. So the call has to be where it runs once: in main, before any loop.

fn main() {
    let t: [i16; 10] = load_resource("squares");
    loop {
        let i = inp() as usize;
        out(t[i]);
    }
}

In a terminal: cargo cardiac help RCE0025.