Title is probably a bit confusing, what I mean is that when I try to compile:
if folder_file_paths.len() > compressed_data.len() {
compressed_data.reserve(folder_file_paths.len() - compressed_data.len() );
}
I get this error:
error[E0502]: cannot borrow `compressed_data` as immutable because it is also borrowed as mutable
--> src/ImageMatching/main.rs:33:59
|
33 | compressed_data.reserve(folder_file_paths.len() - compressed_data.len() );
| --------------- ^^^^^^^^^^^^^^^ - mutable borrow ends here
| | |
| mutable borrow occurs here immutable borrow occurs here
But I can't think of a reason why this is a problem, as shouldn't the argument be processed first, the resulting usize
value be copied, and then the reserve
function run?
When would the argument of a function be calculated after the actual function starts executing?
Edit: folder_file_path
is a Vec
, and compressed_data
is a HashMap