Hi everyone,
When I run the following code:
fn main() {
let array = [7, 1, 2, 3, 4, 5, 6];
let mut iter_array = array.iter().cycle();
iter_array.next();
let vec: Vec<_> = iter_array.collect();
}
Rust exits with panic when it tries to collect the iterator into the vector:
❯ cargo run --bin array-rotate-array
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Running `target\debug\array-rotate-array.exe`
thread 'main' panicked at 'capacity overflow', library\alloc\src\raw_vec.rs:525:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: process didn't exit successfully: `target\debug\array-rotate-array.exe` (exit code: 101)
I'm not sure what is going on so any guidance would be appreciated. Thanks.