Skip to content

Commit

Permalink
Deprecate SockAddr/InetAddr::to_str
Browse files Browse the repository at this point in the history
  • Loading branch information
coolreader18 committed Aug 20, 2021
1 parent 7207004 commit d5481b8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
(#[1447](https://github.com/nix-rust/nix/pull/1447))

## [0.22.0] - 9 July 2021
### Added
- Added `if_nameindex` (#[1445](https://github.com/nix-rust/nix/pull/1445))
Expand Down
2 changes: 2 additions & 0 deletions src/sys/socket/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ impl InetAddr {
}
}

#[deprecated(since = "0.23.0", note = "use .to_string() instead")]
pub fn to_str(&self) -> String {
format!("{}", self)
}
Expand Down Expand Up @@ -722,6 +723,7 @@ impl SockAddr {
}
}

#[deprecated(since = "0.23.0", note = "use .to_string() instead")]
pub fn to_str(&self) -> String {
format!("{}", self)
}
Expand Down
6 changes: 3 additions & 3 deletions test/sys/test_socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit d5481b8

Please sign in to comment.