nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.22k stars 42 forks source link

Fix compiler error: cannot borrow `package.name` as immutable #117

Closed philip-peterson closed 4 years ago

philip-peterson commented 4 years ago

This PR fixes the following compiler error (same as issue #116):

error[E0502]: cannot borrow `package.name` as immutable because `*package` is also borrowed as mutable
  --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/cargo-update-2.3.0/src/main.rs:98:49
   |
96 |         package.pull_version(&latest_registry.as_commit().unwrap().tree().unwrap(),
   |         ------- mutable borrow occurs here
97 |                              &registry_repo,
98 |                              configuration.get(&package.name).and_then(|c| c.install_prereleases));
   |                                                 ^^^^^^^^^^^^ immutable borrow occurs here        - mutable borrow ends here
nabijaczleweli commented 4 years ago

Replaced with https://github.com/nabijaczleweli/cargo-update/commit/e5560c9788d9e15f55552d7e4541c2640d39a95e which avoids that copy but thanks for pointing me in the right direxion with this!

nabijaczleweli commented 4 years ago

Equivalent released in v2.3.1

philip-peterson commented 4 years ago

@nabijaczleweli Thank you for the quick fix!