Closed
Description
So for the following code:
let tmp = if let (Ok(_src_path), Ok(_dest_path)) =
(Path::new(&src_path).strip_prefix(&cur_dir),
Path::new(&dest_path).strip_prefix(&cur_dir)) {
(_src_path.to_path_buf(), _dest_path.to_path_buf())
} else {
(src_path, dest_path)
};
I get the following error:
error[E0505]: cannot move out of `src_path` because it is borrowed
--> src/libsyntax/parse/parser.rs:5249:30
|
5245 | (Path::new(&src_path).strip_prefix(&cur_dir),
| -------- borrow of `src_path` occurs here
...
5249 | (src_path, dest_path)
| ^^^^^^^^ move out of `src_path` occurs here
error[E0505]: cannot move out of `dest_path` because it is borrowed
--> src/libsyntax/parse/parser.rs:5249:40
|
5246 | Path::new(&dest_path).strip_prefix(&cur_dir)) {
| --------- borrow of `dest_path` occurs here
...
5249 | (src_path, dest_path)
| ^^^^^^^^^ move out of `dest_path` occurs here
error: aborting due to 2 previous errors
However, since we're out of the if
scope, shouldn't I be able to use src_path
and dest_path
again?