about summary refs log tree commit diff
path: root/library/std/src/net
diff options
context:
space:
mode:
Diffstat (limited to 'library/std/src/net')
-rw-r--r--library/std/src/net/addr/tests.rs30
-rw-r--r--library/std/src/net/tcp.rs10
-rw-r--r--library/std/src/net/tcp/tests.rs11
-rw-r--r--library/std/src/net/udp.rs14
-rw-r--r--library/std/src/net/udp/tests.rs6
5 files changed, 35 insertions, 36 deletions
diff --git a/library/std/src/net/addr/tests.rs b/library/std/src/net/addr/tests.rs
index 40f5a84bcd5..585a17451a0 100644
--- a/library/std/src/net/addr/tests.rs
+++ b/library/std/src/net/addr/tests.rs
@@ -169,30 +169,30 @@ fn is_v6() {
 fn socket_v4_to_str() {
     let socket = SocketAddrV4::new(Ipv4Addr::new(192, 168, 0, 1), 8080);
 
-    assert_eq!(format!("{}", socket), "192.168.0.1:8080");
-    assert_eq!(format!("{:<20}", socket), "192.168.0.1:8080    ");
-    assert_eq!(format!("{:>20}", socket), "    192.168.0.1:8080");
-    assert_eq!(format!("{:^20}", socket), "  192.168.0.1:8080  ");
-    assert_eq!(format!("{:.10}", socket), "192.168.0.");
+    assert_eq!(format!("{socket}"), "192.168.0.1:8080");
+    assert_eq!(format!("{socket:<20}"), "192.168.0.1:8080    ");
+    assert_eq!(format!("{socket:>20}"), "    192.168.0.1:8080");
+    assert_eq!(format!("{socket:^20}"), "  192.168.0.1:8080  ");
+    assert_eq!(format!("{socket:.10}"), "192.168.0.");
 }
 
 #[test]
 fn socket_v6_to_str() {
     let mut socket = SocketAddrV6::new(Ipv6Addr::new(0x2a02, 0x6b8, 0, 1, 0, 0, 0, 1), 53, 0, 0);
 
-    assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1]:53");
-    assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1]:53    ");
-    assert_eq!(format!("{:>24}", socket), "    [2a02:6b8:0:1::1]:53");
-    assert_eq!(format!("{:^24}", socket), "  [2a02:6b8:0:1::1]:53  ");
-    assert_eq!(format!("{:.15}", socket), "[2a02:6b8:0:1::");
+    assert_eq!(format!("{socket}"), "[2a02:6b8:0:1::1]:53");
+    assert_eq!(format!("{socket:<24}"), "[2a02:6b8:0:1::1]:53    ");
+    assert_eq!(format!("{socket:>24}"), "    [2a02:6b8:0:1::1]:53");
+    assert_eq!(format!("{socket:^24}"), "  [2a02:6b8:0:1::1]:53  ");
+    assert_eq!(format!("{socket:.15}"), "[2a02:6b8:0:1::");
 
     socket.set_scope_id(5);
 
-    assert_eq!(format!("{}", socket), "[2a02:6b8:0:1::1%5]:53");
-    assert_eq!(format!("{:<24}", socket), "[2a02:6b8:0:1::1%5]:53  ");
-    assert_eq!(format!("{:>24}", socket), "  [2a02:6b8:0:1::1%5]:53");
-    assert_eq!(format!("{:^24}", socket), " [2a02:6b8:0:1::1%5]:53 ");
-    assert_eq!(format!("{:.18}", socket), "[2a02:6b8:0:1::1%5");
+    assert_eq!(format!("{socket}"), "[2a02:6b8:0:1::1%5]:53");
+    assert_eq!(format!("{socket:<24}"), "[2a02:6b8:0:1::1%5]:53  ");
+    assert_eq!(format!("{socket:>24}"), "  [2a02:6b8:0:1::1%5]:53");
+    assert_eq!(format!("{socket:^24}"), " [2a02:6b8:0:1::1%5]:53 ");
+    assert_eq!(format!("{socket:.18}"), "[2a02:6b8:0:1::1%5");
 }
 
 #[test]
diff --git a/library/std/src/net/tcp.rs b/library/std/src/net/tcp.rs
index cc4e4fd4fdc..f5d3c4905e0 100644
--- a/library/std/src/net/tcp.rs
+++ b/library/std/src/net/tcp.rs
@@ -595,10 +595,10 @@ impl TcpStream {
     ///             // via platform-specific APIs such as epoll or IOCP
     ///             wait_for_fd();
     ///         }
-    ///         Err(e) => panic!("encountered IO error: {}", e),
+    ///         Err(e) => panic!("encountered IO error: {e}"),
     ///     };
     /// };
-    /// println!("bytes: {:?}", buf);
+    /// println!("bytes: {buf:?}");
     /// ```
     #[stable(feature = "net2_mutators", since = "1.9.0")]
     pub fn set_nonblocking(&self, nonblocking: bool) -> io::Result<()> {
@@ -799,8 +799,8 @@ impl TcpListener {
     ///
     /// let listener = TcpListener::bind("127.0.0.1:8080").unwrap();
     /// match listener.accept() {
-    ///     Ok((_socket, addr)) => println!("new client: {:?}", addr),
-    ///     Err(e) => println!("couldn't get client: {:?}", e),
+    ///     Ok((_socket, addr)) => println!("new client: {addr:?}"),
+    ///     Err(e) => println!("couldn't get client: {e:?}"),
     /// }
     /// ```
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -991,7 +991,7 @@ impl TcpListener {
     ///             wait_for_fd();
     ///             continue;
     ///         }
-    ///         Err(e) => panic!("encountered IO error: {}", e),
+    ///         Err(e) => panic!("encountered IO error: {e}"),
     ///     }
     /// }
     /// ```
diff --git a/library/std/src/net/tcp/tests.rs b/library/std/src/net/tcp/tests.rs
index 4d5cf658def..8c0adcfb0eb 100644
--- a/library/std/src/net/tcp/tests.rs
+++ b/library/std/src/net/tcp/tests.rs
@@ -142,8 +142,7 @@ fn write_close() {
                     e.kind() == ErrorKind::ConnectionReset
                         || e.kind() == ErrorKind::BrokenPipe
                         || e.kind() == ErrorKind::ConnectionAborted,
-                    "unknown error: {}",
-                    e
+                    "unknown error: {e}"
                 );
             }
         }
@@ -655,7 +654,7 @@ fn debug() {
         inner_name,
         render_inner(&listener)
     );
-    assert_eq!(format!("{:?}", listener), compare);
+    assert_eq!(format!("{listener:?}"), compare);
 
     let stream = t!(TcpStream::connect(&("localhost", socket_addr.port())));
     let compare = format!(
@@ -665,7 +664,7 @@ fn debug() {
         inner_name,
         render_inner(&stream)
     );
-    assert_eq!(format!("{:?}", stream), compare);
+    assert_eq!(format!("{stream:?}"), compare);
 }
 
 // FIXME: re-enabled openbsd tests once their socket timeout code
@@ -832,7 +831,7 @@ fn set_nonblocking() {
     match stream.read(&mut buf) {
         Ok(_) => panic!("expected error"),
         Err(ref e) if e.kind() == ErrorKind::WouldBlock => {}
-        Err(e) => panic!("unexpected error {}", e),
+        Err(e) => panic!("unexpected error {e}"),
     }
 }
 
@@ -862,7 +861,7 @@ fn peek() {
         match c.peek(&mut b) {
             Ok(_) => panic!("expected error"),
             Err(ref e) if e.kind() == ErrorKind::WouldBlock => {}
-            Err(e) => panic!("unexpected error {}", e),
+            Err(e) => panic!("unexpected error {e}"),
         }
         t!(txdone.send(()));
     })
diff --git a/library/std/src/net/udp.rs b/library/std/src/net/udp.rs
index 11a696e92c8..864e1b0f345 100644
--- a/library/std/src/net/udp.rs
+++ b/library/std/src/net/udp.rs
@@ -605,9 +605,9 @@ impl UdpSocket {
     ///
     /// let socket = UdpSocket::bind("127.0.0.1:34254").expect("couldn't bind to address");
     /// match socket.take_error() {
-    ///     Ok(Some(error)) => println!("UdpSocket error: {:?}", error),
+    ///     Ok(Some(error)) => println!("UdpSocket error: {error:?}"),
     ///     Ok(None) => println!("No error"),
-    ///     Err(error) => println!("UdpSocket.take_error failed: {:?}", error),
+    ///     Err(error) => println!("UdpSocket.take_error failed: {error:?}"),
     /// }
     /// ```
     #[stable(feature = "net2_mutators", since = "1.9.0")]
@@ -686,8 +686,8 @@ impl UdpSocket {
     /// socket.connect("127.0.0.1:8080").expect("connect function failed");
     /// let mut buf = [0; 10];
     /// match socket.recv(&mut buf) {
-    ///     Ok(received) => println!("received {} bytes {:?}", received, &buf[..received]),
-    ///     Err(e) => println!("recv function failed: {:?}", e),
+    ///     Ok(received) => println!("received {received} bytes {:?}", &buf[..received]),
+    ///     Err(e) => println!("recv function failed: {e:?}"),
     /// }
     /// ```
     #[stable(feature = "net2_mutators", since = "1.9.0")]
@@ -726,8 +726,8 @@ impl UdpSocket {
     /// socket.connect("127.0.0.1:8080").expect("connect function failed");
     /// let mut buf = [0; 10];
     /// match socket.peek(&mut buf) {
-    ///     Ok(received) => println!("received {} bytes", received),
-    ///     Err(e) => println!("peek function failed: {:?}", e),
+    ///     Ok(received) => println!("received {received} bytes"),
+    ///     Err(e) => println!("peek function failed: {e:?}"),
     /// }
     /// ```
     #[stable(feature = "peek", since = "1.18.0")]
@@ -770,7 +770,7 @@ impl UdpSocket {
     ///             // via platform-specific APIs such as epoll or IOCP
     ///             wait_for_fd();
     ///         }
-    ///         Err(e) => panic!("encountered IO error: {}", e),
+    ///         Err(e) => panic!("encountered IO error: {e}"),
     ///     }
     /// };
     /// println!("bytes: {:?}", &buf[..num_bytes_read]);
diff --git a/library/std/src/net/udp/tests.rs b/library/std/src/net/udp/tests.rs
index a51113dd9e7..f82904ffbbf 100644
--- a/library/std/src/net/udp/tests.rs
+++ b/library/std/src/net/udp/tests.rs
@@ -173,8 +173,8 @@ fn debug() {
 
     let udpsock = t!(UdpSocket::bind(&socket_addr));
     let udpsock_inner = udpsock.0.socket().as_raw();
-    let compare = format!("UdpSocket {{ addr: {:?}, {}: {:?} }}", socket_addr, name, udpsock_inner);
-    assert_eq!(format!("{:?}", udpsock), compare);
+    let compare = format!("UdpSocket {{ addr: {socket_addr:?}, {name}: {udpsock_inner:?} }}");
+    assert_eq!(format!("{udpsock:?}"), compare);
 }
 
 // FIXME: re-enabled openbsd/netbsd tests once their socket timeout code
@@ -359,7 +359,7 @@ fn set_nonblocking() {
         match socket.recv(&mut buf) {
             Ok(_) => panic!("expected error"),
             Err(ref e) if e.kind() == ErrorKind::WouldBlock => {}
-            Err(e) => panic!("unexpected error {}", e),
+            Err(e) => panic!("unexpected error {e}"),
         }
     })
 }