Skip to content

Commit

Permalink
Update to indexmap 2 (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Dec 30, 2024
1 parent 92890cd commit 122c0e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ members = ["examples/*"]

[dependencies]
bytes = "1.4"
indexmap = "1.9"
indexmap = "2"
rand = { version = "0.8.5", features = ["small_rng"] }
rand_distr = "0.4.3"
regex = { version = "1", optional = true }
Expand Down
12 changes: 7 additions & 5 deletions src/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Udp {
}

pub(crate) fn unbind(&mut self, addr: SocketAddr) {
let exists = self.binds.remove(&addr.port());
let exists = self.binds.swap_remove(&addr.port());

assert!(exists.is_some(), "unknown bind {addr}");

Expand Down Expand Up @@ -306,7 +306,7 @@ impl StreamSocket {
while self.buf.contains_key(&(self.recv_seq + 1)) {
self.recv_seq += 1;

let segment = self.buf.remove(&self.recv_seq).unwrap();
let segment = self.buf.swap_remove(&self.recv_seq).unwrap();
self.sender.try_send(segment).map_err(|e| match e {
Closed(_) => Protocol::Tcp(Segment::Rst),
Full(_) => panic!("{} socket buffer full", self.local_addr),
Expand Down Expand Up @@ -407,7 +407,9 @@ impl Tcp {
},
Segment::Rst => {
if self.sockets.get(&SocketPair::new(dst, src)).is_some() {
self.sockets.remove(&SocketPair::new(dst, src)).unwrap();
self.sockets
.swap_remove(&SocketPair::new(dst, src))
.unwrap();
}
}
};
Expand All @@ -422,13 +424,13 @@ impl Tcp {
sock.ref_ct -= 1;

if sock.ref_ct == 0 {
self.sockets.remove(&pair).unwrap();
self.sockets.swap_remove(&pair).unwrap();
}
}
}

pub(crate) fn unbind(&mut self, addr: SocketAddr) {
let exists = self.binds.remove(&addr.port());
let exists = self.binds.swap_remove(&addr.port());

assert!(exists.is_some(), "unknown bind {addr}");

Expand Down

0 comments on commit 122c0e6

Please sign in to comment.