Skip to content

Commit

Permalink
refactor(SendStream): remove borrow-checker work-around
Browse files Browse the repository at this point in the history
With recent Rust versions, the Rust borrow-checker has become more capable,
especially when it comes to borrowing subsets of `self`.

This commit removes the no longer necessary borrow-checker work-around.
  • Loading branch information
mxinden committed Apr 15, 2024
1 parent cf00098 commit a902432
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions neqo-transport/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1634,20 +1634,16 @@ impl SendStreams {
}

pub fn remove_terminal(&mut self) {
let map: &mut IndexMap<StreamId, SendStream> = &mut self.map;
let regular: &mut OrderGroup = &mut self.regular;
let sendordered: &mut BTreeMap<SendOrder, OrderGroup> = &mut self.sendordered;

// Take refs to all the items we need to modify instead of &mut
// self to keep the compiler happy (if we use self.map.retain it
// gets upset due to borrows)
map.retain(|stream_id, stream| {
self.map.retain(|stream_id, stream| {
if stream.is_terminal() {
if stream.is_fair() {
match stream.sendorder() {
None => regular.remove(*stream_id),
None => self.regular.remove(*stream_id),
Some(sendorder) => {
sendordered.get_mut(&sendorder).unwrap().remove(*stream_id);
self.sendordered
.get_mut(&sendorder)
.unwrap()
.remove(*stream_id);
}
};
}
Expand Down

0 comments on commit a902432

Please sign in to comment.