-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #76226 - CDirkx:const-ipaddr, r=dtolnay
Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `std::net::IpAddr` as const, in the same way as [PR#76198](#76198). Possible because of the recent stabilization of const control flow. Part of #76225 and #76205.
- Loading branch information
Showing
2 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// run-pass | ||
|
||
use std::net::{IpAddr, Ipv4Addr}; | ||
|
||
fn main() { | ||
const IP_ADDRESS : IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST); | ||
|
||
const IS_IP_V4 : bool = IP_ADDRESS.is_ipv4(); | ||
assert!(IS_IP_V4); | ||
|
||
const IS_IP_V6 : bool = IP_ADDRESS.is_ipv6(); | ||
assert!(!IS_IP_V6); | ||
} |