标题可能有点令人困惑,我的意思是当我尝试编译时:
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