Relative Content

Tag Archive for rustvectormutable

error[E0499]: cannot borrow `new_vector` as mutable more than once at a time

for (i, element) in new_vector.iter_mut().enumerate() { let new_element = array[i as usize] + array[i as usize – 1]; println!(“Element {}”, *element); println!(“New Element {}”, new_element); println!(“Count {}”, i); new_vector[i as usize + 1] = new_element; } This doesn’t work due to barrowing twice. The documents are non-existent. Nothing explains something I know is simple. I […]

Rust – error[E0499]: cannot borrow `new_vector` as mutable more than once at a time

for (i, element) in new_vector.iter_mut().enumerate() { let new_element = array[i as usize] + array[i as usize – 1]; println!(“Element {}”, *element); println!(“New Element {}”, new_element); println!(“Count {}”, i); new_vector[i as usize + 1] = new_element; } This doesn’t work due to barrowing twice. The documents are non-existent. Nothing explains something I know is simple. I […]