Skip to content

Commit c96141d

Browse files
committed
Deprecate SockAddr/InetAddr::to_str
1 parent 7207004 commit c96141d

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
7878
Rustc and Xcode.
7979
(#[1492](https://github.com/nix-rust/nix/pull/1492))
8080

81+
- Deprecated `SockAddr/InetAddr::to_str` in favor of `ToString::to_string`
82+
(#[1495](https://github.com/nix-rust/nix/pull/1495))
83+
8184
## [0.22.0] - 9 July 2021
8285
### Added
8386
- Added `if_nameindex` (#[1445](https://github.com/nix-rust/nix/pull/1445))

src/sys/socket/addr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,7 @@ impl InetAddr {
344344
}
345345
}
346346

347+
#[deprecated(since = "0.23.0", note = "use .to_string() instead")]
347348
pub fn to_str(&self) -> String {
348349
format!("{}", self)
349350
}
@@ -722,6 +723,7 @@ impl SockAddr {
722723
}
723724
}
724725

726+
#[deprecated(since = "0.23.0", note = "use .to_string() instead")]
725727
pub fn to_str(&self) -> String {
726728
format!("{}", self)
727729
}

test/sys/test_socket.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub fn test_inetv4_addr_to_sock_addr() {
2828
_ => panic!("nope"),
2929
}
3030

31-
assert_eq!(addr.to_str(), "127.0.0.1:3000");
31+
assert_eq!(addr.to_string(), "127.0.0.1:3000");
3232

3333
let inet = addr.to_std();
3434
assert_eq!(actual, inet);
@@ -194,8 +194,8 @@ pub fn test_getsockname() {
194194
.expect("socket failed");
195195
let sockaddr = SockAddr::new_unix(&sockname).unwrap();
196196
bind(sock, &sockaddr).expect("bind failed");
197-
assert_eq!(sockaddr.to_str(),
198-
getsockname(sock).expect("getsockname failed").to_str());
197+
assert_eq!(sockaddr.to_string(),
198+
getsockname(sock).expect("getsockname failed").to_string());
199199
}
200200

201201
#[test]

0 commit comments

Comments
 (0)