Skip to content

Commit

Permalink
Resolve mutable_borrow_reservation_conflict warning
Browse files Browse the repository at this point in the history
    warning: cannot borrow `*set` as mutable because it is also borrowed as immutable
       --> src/main.rs:451:13
        |
    450 |           if let Some(first) = set.iter().next() {
        |                                ---------- immutable borrow occurs here
    451 | /             set.insert(Star {
    452 | |                 time: first.time - Duration::seconds(1),
        | |                       ---------- immutable borrow later used here
    453 | |                 node: Default::default(),
    454 | |             });
        | |______________^ mutable borrow occurs here
        |
        = note: `#[warn(mutable_borrow_reservation_conflict)]` on by default
        = warning: this borrowing pattern was not meant to be accepted, and may become a hard error in the future
        = note: for more information, see issue #59159 <rust-lang/rust#59159>
  • Loading branch information
dtolnay committed Jan 19, 2022
1 parent c6f555f commit d1d928a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -448,8 +448,9 @@ fn try_main(log: &mut Log) -> Result<()> {
let now = Utc::now();
for set in stars.values_mut() {
if let Some(first) = set.iter().next() {
let first_time = first.time;
set.insert(Star {
time: first.time - Duration::seconds(1),
time: first_time - Duration::seconds(1),
node: Default::default(),
});
}
Expand Down

0 comments on commit d1d928a

Please sign in to comment.