I am trying to obtain a reference to the last value of a vector to simplify referencing it in the following code.
fn calculate_errors(&mut self, targets: &[f64]) -> () {r
let ref mut last_layer = self.vector[self.vector.len() - 1];
for i in 0..last_layer.len() {
last_layer[i].error = targets[i] - last_layer[i].value;
}
}
In my attempt here I get the error:
error[E0502]: cannot borrow
self.vector
as immutable because it is also borrowed as mutable
What would be the proper way to do this? How could I fix this?