From c96141d423eb415ba9720519794f6448044006f0 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Mon, 7 Jun 2021 23:07:45 -0500 Subject: [PATCH] Deprecate SockAddr/InetAddr::to_str --- CHANGELOG.md | 3 +++ src/sys/socket/addr.rs | 2 ++ test/sys/test_socket.rs | 6 +++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ccbe81bb6..deab2cf572 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,9 @@ This project adheres to [Semantic Versioning](https://semver.org/). Rustc and Xcode. (#[1492](https://github.com/nix-rust/nix/pull/1492)) +- Deprecated `SockAddr/InetAddr::to_str` in favor of `ToString::to_string` + (#[1495](https://github.com/nix-rust/nix/pull/1495)) + ## [0.22.0] - 9 July 2021 ### Added - Added `if_nameindex` (#[1445](https://github.com/nix-rust/nix/pull/1445)) diff --git a/src/sys/socket/addr.rs b/src/sys/socket/addr.rs index a964d61bdb..0f907bbe82 100644 --- a/src/sys/socket/addr.rs +++ b/src/sys/socket/addr.rs @@ -344,6 +344,7 @@ impl InetAddr { } } + #[deprecated(since = "0.23.0", note = "use .to_string() instead")] pub fn to_str(&self) -> String { format!("{}", self) } @@ -722,6 +723,7 @@ impl SockAddr { } } + #[deprecated(since = "0.23.0", note = "use .to_string() instead")] pub fn to_str(&self) -> String { format!("{}", self) } diff --git a/test/sys/test_socket.rs b/test/sys/test_socket.rs index c43d0672ec..92bb30e0f4 100644 --- a/test/sys/test_socket.rs +++ b/test/sys/test_socket.rs @@ -28,7 +28,7 @@ pub fn test_inetv4_addr_to_sock_addr() { _ => panic!("nope"), } - assert_eq!(addr.to_str(), "127.0.0.1:3000"); + assert_eq!(addr.to_string(), "127.0.0.1:3000"); let inet = addr.to_std(); assert_eq!(actual, inet); @@ -194,8 +194,8 @@ pub fn test_getsockname() { .expect("socket failed"); let sockaddr = SockAddr::new_unix(&sockname).unwrap(); bind(sock, &sockaddr).expect("bind failed"); - assert_eq!(sockaddr.to_str(), - getsockname(sock).expect("getsockname failed").to_str()); + assert_eq!(sockaddr.to_string(), + getsockname(sock).expect("getsockname failed").to_string()); } #[test]