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.
This commit is contained in:
parent
4ec27e4b79
commit
3f8fdf83ff
2 changed files with 17 additions and 2 deletions
13
src/test/ui/consts/std/net/ip.rs
Normal file
13
src/test/ui/consts/std/net/ip.rs
Normal file
|
|
@ -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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue