macro_rules! ip_addr {
(v4, $s:expr) => { ... };
(v6, $s:expr) => { ... };
($s:expr) => { ... };
}
Expand description
Converts a string slice to an IP address.
This macro requires the feature std
.
Examples
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use const_str::ip_addr;
const LOCALHOST_V4: Ipv4Addr = ip_addr!(v4, "127.0.0.1");
const LOCALHOST_V6: Ipv6Addr = ip_addr!(v6, "::1");
const LOCALHOSTS: [IpAddr;2] = [ip_addr!("127.0.0.1"), ip_addr!("::1")];