diff options
| author | Christiaan Dirkx <christiaan@dirkx.email> | 2020-09-02 02:05:42 +0200 |
|---|---|---|
| committer | Christiaan Dirkx <christiaan@dirkx.email> | 2020-11-23 01:33:46 +0100 |
| commit | 3f8fdf83ff2182938b29b93cbf92aec62e1f96cd (patch) | |
| tree | 68bc7ef6acd215e94c53c9354e51af9dc0f8fdf4 /src | |
| parent | 4ec27e4b79891b0ebc2ad71a3c4ac94f67d93f93 (diff) | |
| download | rust-3f8fdf83ff2182938b29b93cbf92aec62e1f96cd.tar.gz rust-3f8fdf83ff2182938b29b93cbf92aec62e1f96cd.zip | |
Stabilize `IpAddr::is_ipv4` and `is_ipv6` as const
Insta-stabilize the methods `is_ipv4` and `is_ipv6` of `IpAddr`. Possible because of the recent stabilization of const control flow. Also adds a test for these methods in a const context.
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/consts/std/net/ip.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/test/ui/consts/std/net/ip.rs b/src/test/ui/consts/std/net/ip.rs new file mode 100644 index 00000000000..6730946577d --- /dev/null +++ b/src/test/ui/consts/std/net/ip.rs @@ -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); +} |
