Skip to content

Commit 426b09a

Browse files
Merge #1495
1495: Deprecate SockAddr/InetAddr::to_str r=asomers a=coolreader18 Co-authored-by: Noah <[email protected]>
2 parents 8866df6 + c96141d commit 426b09a

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
@@ -80,6 +80,9 @@ This project adheres to [Semantic Versioning](https://semver.org/).
8080
Rustc and Xcode.
8181
(#[1492](https://github.com/nix-rust/nix/pull/1492))
8282

83+
- Deprecated `SockAddr/InetAddr::to_str` in favor of `ToString::to_string`
84+
(#[1495](https://github.com/nix-rust/nix/pull/1495))
85+
8386
## [0.22.0] - 9 July 2021
8487
### Added
8588
- 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)