タイトルはおそらく少し紛らわしいですが、コンパイルしようとすると、次のようになります。
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