We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8cd7351 commit 230441eCopy full SHA for 230441e
library/std/src/net/ip/tests.rs
@@ -944,3 +944,26 @@ fn ip_const() {
944
const IS_IP_V6: bool = IP_ADDRESS.is_ipv6();
945
assert!(!IS_IP_V6);
946
}
947
+
948
+#[test]
949
+fn structural_match() {
950
+ // test that all IP types can be structurally matched upon
951
952
+ const IPV4: Ipv4Addr = Ipv4Addr::LOCALHOST;
953
+ match IPV4 {
954
+ Ipv4Addr::LOCALHOST => {}
955
+ _ => unreachable!(),
956
+ }
957
958
+ const IPV6: Ipv6Addr = Ipv6Addr::LOCALHOST;
959
+ match IPV6 {
960
+ Ipv6Addr::LOCALHOST => {}
961
962
963
964
+ const IP: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST);
965
+ match IP {
966
+ IpAddr::V4(Ipv4Addr::LOCALHOST) => {}
967
968
969
+}
0 commit comments