0

New to Rust, and ran into this error thread 'main' has overflowed its stack for this code:

fn main() {
    const N: usize = 10_000_000;
    let mut a: [u8; N]= [1; N];
    a[0] = 0;
}

It is ok for N = 1_000_000. Is there a better way to allocate long array?

Jingshao Chen
  • 3,405
  • 2
  • 26
  • 34

0 Answers0