about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2020-11-23 04:47:25 +0000
committerbors <bors@rust-lang.org>2020-11-23 04:47:25 +0000
commit1823a87986c6acf0765c0101d75bca5328416a60 (patch)
treeb44fb72ecd0d71180f089f3a8637be72f0f98e0b /src
parentf32459c7ba767e7f26e3c4c4bd6be326d83bcb78 (diff)
parent4613bc96a4dd8b492623aac79d91314041d17af0 (diff)
downloadrust-1823a87986c6acf0765c0101d75bca5328416a60.tar.gz
rust-1823a87986c6acf0765c0101d75bca5328416a60.zip
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](https://github.com/rust-lang/rust/pull/76198).

Possible because of the recent stabilization of const control flow.

Part of #76225 and #76205.
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/std/net/ip.rs13
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);
+}