Skip to content

Commit 47c2845

Browse files
committed
Address CR comments
Signed-off-by: Joe Grund <grundjoseph@gmail.com>
1 parent 3efb49c commit 47c2845

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

src/host.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,17 +277,12 @@ impl Udp {
277277

278278
Ok(UdpSocket::new(addr, rx))
279279
}
280-
pub(crate) fn connect(&mut self, src: SocketAddr, dst: SocketAddr) -> io::Result<()> {
280+
pub(crate) fn connect(&mut self, src: SocketAddr, dst: SocketAddr) {
281281
let Some(bind) = self.binds.get_mut(&src.port()) else {
282-
return Err(io::Error::new(
283-
io::ErrorKind::NotFound,
284-
"Connect failed (no matching bind) for {src}",
285-
));
282+
panic!("Connect failed (no matching bind) for {src}");
286283
};
287284

288285
bind.target_addr = Some(dst);
289-
290-
Ok(())
291286
}
292287

293288
fn receive_from_network(&mut self, src: SocketAddr, dst: SocketAddr, datagram: Datagram) {

src/net/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,12 @@ impl UdpSocket {
156156
}),
157157
}
158158
}
159-
pub async fn connect<A: ToSocketAddrs>(&self, addr: A) -> io::Result<()> {
159+
pub async fn connect<A: ToSocketAddrs>(&self, addr: A) {
160160
World::current(|world| {
161161
let addr = addr.to_socket_addr(&world.dns);
162162
let host = world.current_host_mut();
163163

164-
host.udp.connect(self.local_addr, addr)
164+
host.udp.connect(self.local_addr, addr);
165165
})
166166
}
167167

tests/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,7 +1046,7 @@ fn try_recv_connected() -> Result {
10461046
sim.client("server1", async move {
10471047
let sock = UdpSocket::bind((Ipv4Addr::UNSPECIFIED, 1234)).await?;
10481048

1049-
sock.connect(("server2", 5678)).await?;
1049+
sock.connect(("server2", 5678)).await;
10501050

10511051
sock.readable().await?;
10521052

@@ -1079,7 +1079,7 @@ fn try_recv_connected_wrong_host() -> Result {
10791079
let sock = UdpSocket::bind((Ipv4Addr::UNSPECIFIED, 1234)).await?;
10801080

10811081
// Connect to server3, which doesn't send anything.
1082-
sock.connect(("server3", 6781)).await?;
1082+
sock.connect(("server3", 6781)).await;
10831083

10841084
// Datagram from server2 is filtered so sock never becomes readable.
10851085
tokio::time::timeout(Duration::from_secs(5), sock.readable())

0 commit comments

Comments
 (0)