Skip to content

Commit 61c1c83

Browse files
committed
Remove unneccessary String::from around format!() output
It's already a String
1 parent 3b1d07a commit 61c1c83

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/resolver/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,13 +420,13 @@ async fn check_port(
420420
host: String, // The host name
421421
timeout: Duration, // The timeout duration for the TCP connection
422422
) -> (String, String) {
423-
let https_with_port = String::from(format!("{}{}:{}", "https://", host, port)); // Construct the HTTPS URL with the port
424-
let http_with_port = String::from(format!("{}{}:{}", "http://", host, port)); // Construct the HTTP URL with the port
423+
let https_with_port = format!("{}{}:{}", "https://", host, port); // Construct the HTTPS URL with the port
424+
let http_with_port = format!("{}{}:{}", "http://", host, port); // Construct the HTTP URL with the port
425425
if port == 80 {
426426
let socket_address = SocketAddr::new(ip_addr.clone(), port); // Create a socket address using the IP address and port
427427

428428
// If the TCP connection is successful, print the HTTP URL with the port
429-
let ip = String::from(format!("{}{}:{}", "http://", ip_addr.to_string(), port));
429+
let ip = format!("{}{}:{}", "http://", ip_addr.to_string(), port);
430430

431431
match tokio::time::timeout(timeout, TcpStream::connect(&socket_address)).await {
432432
Ok(Ok(_)) => {
@@ -439,7 +439,7 @@ async fn check_port(
439439
}
440440
} else if port == 443 {
441441
// If the TCP connection is successful, print the HTTPS URL with the port
442-
let ip = String::from(format!("{}{}:{}", "https://", ip_addr.to_string(), port));
442+
let ip = format!("{}{}:{}", "https://", ip_addr.to_string(), port);
443443

444444
let socket_address = SocketAddr::new(ip_addr.clone(), port); // Create a socket address using the IP address and port
445445

@@ -454,7 +454,7 @@ async fn check_port(
454454
}
455455
} else {
456456
// If the TCP connection is successful, print the HTTPS URL with the port
457-
let ip = String::from(format!("{}{}:{}", "https://", ip_addr.to_string(), port));
457+
let ip = format!("{}{}:{}", "https://", ip_addr.to_string(), port);
458458

459459
let socket_address = SocketAddr::new(ip_addr.clone(), port); // Create a socket address using the IP address and port
460460

0 commit comments

Comments
 (0)