标题可能有点混乱,我的意思是当我尝试编译时:
if folder_file_paths.len() > compressed_data.len() {
compressed_data.reserve(folder_file_paths.len() - compressed_data.len() );
}
我收到此错误:
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
但是我想不出这是一个问题的原因,因为不应该先处理参数,usize
复制结果值,然后reserve
运行函数吗?
实际函数开始执行后,何时计算函数的参数?
编辑:folder_file_path
是一个Vec
,并且compressed_data
是一个HashMap