summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNylonicious <50183564+nylonicious@users.noreply.github.com>2020-12-10 20:58:27 +0100
committerGitHub <noreply@github.com>2020-12-10 14:58:27 -0500
commit16c2e0983cc0ab22f9a0b7a1ac37ea32a42b9a6e (patch)
treed46d58a79f31dba872aa060ef378743fcedea70e
parent4b1d76ec8f35052480eb14204d147df658bfdfdd (diff)
downloadtokio-16c2e0983cc0ab22f9a0b7a1ac37ea32a42b9a6e.tar.gz
tokio-16c2e0983cc0ab22f9a0b7a1ac37ea32a42b9a6e.tar.xz
net: Pass SocketAddr by value (#3125)
-rw-r--r--tokio-util/src/udp/frame.rs2
-rw-r--r--tokio/src/net/udp/socket.rs4
-rw-r--r--tokio/tests/udp.rs10
3 files changed, 8 insertions, 8 deletions
diff --git a/tokio-util/src/udp/frame.rs b/tokio-util/src/udp/frame.rs
index 19891058..249acb70 100644
--- a/tokio-util/src/udp/frame.rs
+++ b/tokio-util/src/udp/frame.rs
@@ -130,7 +130,7 @@ impl<I, C: Encoder<I> + Unpin> Sink<(I, SocketAddr)> for UdpFramed<C> {
..
} = *self;
- let n = ready!(socket.poll_send_to(cx, &wr, &out_addr))?;
+ let n = ready!(socket.poll_send_to(cx, &wr, *out_addr))?;
let wrote_all = n == self.wr.len();
self.wr.clear();
diff --git a/tokio/src/net/udp/socket.rs b/tokio/src/net/udp/socket.rs
index a9c5c868..3775714c 100644
--- a/tokio/src/net/udp/socket.rs
+++ b/tokio/src/net/udp/socket.rs
@@ -745,11 +745,11 @@ impl UdpSocket {
&self,
cx: &mut Context<'_>,
buf: &[u8],
- target: &SocketAddr,
+ target: SocketAddr,
) -> Poll<io::Result<usize>> {
self.io
.registration()
- .poll_write_io(cx, || self.io.send_to(buf, *target))
+ .poll_write_io(cx, || self.io.send_to(buf, target))
}
/// Try to send data on the socket to the given address, but if the send is
diff --git a/tokio/tests/udp.rs b/tokio/tests/udp.rs
index 291267e0..7cbba1b3 100644
--- a/tokio/tests/udp.rs
+++ b/tokio/tests/udp.rs
@@ -66,7 +66,7 @@ async fn send_to_recv_from_poll() -> std::io::Result<()> {
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
- poll_fn(|cx| sender.poll_send_to(cx, MSG, &receiver_addr)).await?;
+ poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?;
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
@@ -83,7 +83,7 @@ async fn send_to_peek_from() -> std::io::Result<()> {
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
- poll_fn(|cx| sender.poll_send_to(cx, MSG, &receiver_addr)).await?;
+ poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?;
// peek
let mut recv_buf = [0u8; 32];
@@ -111,7 +111,7 @@ async fn send_to_peek_from_poll() -> std::io::Result<()> {
let receiver = UdpSocket::bind("127.0.0.1:0").await?;
let receiver_addr = receiver.local_addr()?;
- poll_fn(|cx| sender.poll_send_to(cx, MSG, &receiver_addr)).await?;
+ poll_fn(|cx| sender.poll_send_to(cx, MSG, receiver_addr)).await?;
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);
@@ -192,7 +192,7 @@ async fn split_chan_poll() -> std::io::Result<()> {
let (tx, mut rx) = tokio::sync::mpsc::channel::<(Vec<u8>, std::net::SocketAddr)>(1_000);
tokio::spawn(async move {
while let Some((bytes, addr)) = rx.recv().await {
- poll_fn(|cx| s.poll_send_to(cx, &bytes, &addr))
+ poll_fn(|cx| s.poll_send_to(cx, &bytes, addr))
.await
.unwrap();
}
@@ -209,7 +209,7 @@ async fn split_chan_poll() -> std::io::Result<()> {
// test that we can send a value and get back some response
let sender = UdpSocket::bind("127.0.0.1:0").await?;
- poll_fn(|cx| sender.poll_send_to(cx, MSG, &addr)).await?;
+ poll_fn(|cx| sender.poll_send_to(cx, MSG, addr)).await?;
let mut recv_buf = [0u8; 32];
let mut read = ReadBuf::new(&mut recv_buf);